1

I'm trying to run a Python script from Excel using this VBA script.

Sub Plot()

ChDir "M:\Tools and Utilities\ColorScout\ColorScout Data Parser\src"
Shell "C:\Anaconda3\python.exe M:\Tools and Utilities\ColorScout\ColorScout Data Parser\src\Main.py", vbNormalFocus

End Sub

Pretty basic.

However, it's failing on the second line. I get an error message from Python that M:\Tools is not a directory.

What I think is happening is that the spaces in "Tools and Utilities" aren't being recognized. How can I get Python to recognizes Tools and Utilities as a directory? Putting Tools and Utilities in quotation marks raises a syntax error in VBA.

Hope this makes sense. Thank you!

2
  • Try including the full parameter in quotations: "C:\Anaconda3\python.exe ""M:\Tools and Utilities\...\Main.py""" Commented Sep 17, 2015 at 2:19
  • I'm glad it helped. I'll provide an answer as a reference Commented Sep 17, 2015 at 22:05

1 Answer 1

2

Include the full parameter in quotations:

Shell "C:\Anaconda3\python.exe ""M:\Tools and Utilities\...\Main.py"""
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.