0

This works:

Path = "c:\Python27\python.exe"
File = ThisWorkbook.Path & "\Positionly-API-Keyword-Script.py"

This does not work:

Path = "%systemdrive%\Python27\python.exe"
File = ThisWorkbook.Path & "\Positionly-API-Keyword-Script.py"

What gives?

I just want to make my macro more flexible so that it will always find Python 2.7 if it was installed in the default directory (which may or may not be C:)

Ideally I'd like to just variable/path it straight to Python to make it mich more flexible and rigorous in terms of error handling. I just don't know the VBA to do what I want!

4
  • 2
    try Environ function Commented Apr 10, 2017 at 11:15
  • Thanks! That led me to try this: Path = Environ(systemdrive) & "\Python27\python.exe" - but no dice, it still doesn't work... Commented Apr 10, 2017 at 11:18
  • 2
    add quotes like in the answer i have provided. Commented Apr 10, 2017 at 11:19
  • Thanks that works perfectly! Will mark as resolution :) Commented Apr 10, 2017 at 11:22

1 Answer 1

2
path=environ("Systemdrive") & "\python27\python.exe"

you can use the Environ function to get operating system variables.

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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.