Run Python script via VBA and give name and path of active workbook?
<p>EDIT: This is the same question but I rewrote it, so it is more legible.</p>

<p>I already tried this post: <a href="https://stackoverflow.com/questions/18135551/how-to-call-python-script-on-excel-vba">How to call python script on excel vba?</a></p>

<p>And this post: <a href="https://stackoverflow.com/questions/30531662/run-and-execute-a-python-script-from-vba">Run and execute a python script from VBA</a></p>

<p>And this post: <a href="https://stackoverflow.com/questions/7963428/how-can-i-call-python-program-from-vba">How can I call python program from VBA?</a></p>

<p>But none of the answers works for me and I have no idea what I'm doing wrong. Problem 1: I want to run a pythonscript from VBA excel. excel file doesn't have a home place (can be on any desktop). the code I (want to) use:</p>

<pre><code> Dim Ret_Val
 Ret_Val = Shell("C:\python27\python.exe \\10.31.13.22\SharedDocs\3 - Technical\13 - Reports &amp; Templates\13 - Description\DescriptionToDatabase.py")
</code></pre>

<p>The pythonfile has always the same path on the server. I cannot see wat is wrong here? All I get is a black python screen.</p>

<p>In the python file I call the workbook and the correct sheet:</p>

<pre><code>book = xlrd.open_workbook("//10.31.13.22/SharedDocs/3 - Technical/1 - Projects/0 - Internal/RPA 138 - Engineering software/testchipdescription/upload to database/testchipdescription-template-10-11.xltm")
sheet = book.sheet_by_name("Database")
</code></pre>

<p>At the moment the excel workbook path is hardcoded in python. This will bring me back to problem 2: Can I pass the name and path of the excel workbook somehow to my pythonscript? </p>

<p>EDIT:</p>

<p>I tried the shell()code in command prompt.
The same as in VBA: </p>

<pre><code>"C:\python27\python.exe \\10.31.13.22\SharedDocs\3 - Technical\13 - Reports &amp; Templates\13 - Description\DescriptionToDatabase.py"
</code></pre>

<p>It doesn't work. 'The system cannot find the path specified'.</p>

<p>I tried this one: </p>

<pre><code>C:\python27\python.exe "\\10.31.13.22\SharedDocs\3 - Technical\13 - Reports &amp; Templates\13 - Description\DescriptionToDatabase.py"
</code></pre>

<p>And it works! So the cmd needs "" to handle the spaces in the path. But I can't add them in VBA because I cannot place 2 "" otherwise it errors.</p>