Skip to content

Commit

Permalink
allow spaces in PYTHON_WIN, closes #461
Browse files Browse the repository at this point in the history
  • Loading branch information
fzumstein committed May 13, 2016
1 parent 1964de2 commit e9f9cd8
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions xlwings/xlwings.bas
Original file line number Diff line number Diff line change
Expand Up @@ -211,23 +211,25 @@ Sub ExecuteWindows(IsFrozen As Boolean, PythonCommand As String, PYTHON_WIN As S
Dim WaitOnReturn As Boolean: WaitOnReturn = True
Dim WindowStyle As Integer: WindowStyle = 0
Set Wsh = CreateObject("WScript.Shell")
Dim DriveCommand As String, RunCommand As String, WORKBOOK_FULLNAME As String, PythonInterpreter As String
Dim DriveCommand As String, RunCommand As String, WORKBOOK_FULLNAME As String, PythonInterpreter As String, PythonDir As String
Dim ExitCode As Integer

If LOG_FILE = "" Then
LOG_FILE = Environ("APPDATA") + "\xlwings_log.txt"
End If

If Not IsFrozen Then
PYTHON_WIN = ParentFolder(PYTHON_WIN)
If Not IsFrozen And PYTHON_WIN <> "" Then
PythonDir = ParentFolder(PYTHON_WIN)
Else
PythonDir = PYTHON_WIN
End If

If Left$(PYTHON_WIN, 2) Like "[A-Za-z]:" Then
' If Python is installed on a mapped or local drive, change to drive, then cd to path
DriveCommand = Left$(PYTHON_WIN, 2) & " & cd """ & PYTHON_WIN & """ & "
DriveCommand = Left$(PYTHON_WIN, 2) & " & cd """ & PythonDir & """ & "
ElseIf Left$(PYTHON_WIN, 2) = "\\" Then
' If Python is installed on a UNC path, temporarily mount and activate a drive letter with pushd
DriveCommand = "pushd """ & PYTHON_WIN & """ & "
DriveCommand = "pushd """ & PythonDir & """ & "
End If

' Run Python with the "-c" command line switch: add the path of the python file and run the
Expand All @@ -236,7 +238,7 @@ Sub ExecuteWindows(IsFrozen As Boolean, PythonCommand As String, PYTHON_WIN As S
WORKBOOK_FULLNAME = ThisWorkbook.FullName

If PYTHON_WIN <> "" Then
PythonInterpreter = PYTHON_WIN
PythonInterpreter = Chr(34) & PYTHON_WIN & Chr(34)
Else
PythonInterpreter = "python"
End If
Expand Down

0 comments on commit e9f9cd8

Please sign in to comment.