Skip to content

Commit

Permalink
Implemented app_target when calling from Excel, closes #196
Browse files Browse the repository at this point in the history
  • Loading branch information
fzumstein committed Jul 8, 2015
1 parent 2ca018b commit ed05d25
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 7 additions & 2 deletions xlwings/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,13 @@ def my_macro():
elif len(sys.argv) > 2 and sys.argv[2] == 'from_xl':
# Connect to the workbook from which this code has been invoked
fullname = sys.argv[1].lower()
xl_workbook = xlplatform.get_xl_workbook_from_xl(fullname)
return cls(xl_workbook=xl_workbook)
if len(sys.argv) > 3:
# On Mac we additionally send over the Application path
xl_workbook = xlplatform.get_xl_workbook_from_xl(fullname, app_target=sys.argv[3])
return cls(xl_workbook=xl_workbook, app_target=sys.argv[3])
else:
xl_workbook = xlplatform.get_xl_workbook_from_xl(fullname)
return cls(xl_workbook=xl_workbook)
elif xlplatform.get_xl_workbook_current():
# Called through ExcelPython connection
return cls(xl_workbook=xlplatform.get_xl_workbook_current())
Expand Down
4 changes: 2 additions & 2 deletions xlwings/xlwings.bas
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ Sub ExcecuteMac(Command As String, PYTHON_MAC As String, LOG_FILE As String, SHO
'Check if .bash_profile is existing and source it
Res = system("source ~/.bash_profile")
If Res = 0 Then
Res = system("source ~/.bash_profile;" & RunCommand & """" & WORKBOOK_FULLNAME & """ ""from_xl"" >" & Chr(34) & LOG_FILE & Chr(34) & " 2>&1 &")
Res = system("source ~/.bash_profile;" & RunCommand & """" & WORKBOOK_FULLNAME & """ ""from_xl""" & " " & Chr(34) & ToPosixPath(Application.Path) & "/" Application.Name & Chr(34) & ">" & Chr(34) & LOG_FILE & Chr(34) & " 2>&1 &")
Else
Res = system(RunCommand & """" & WORKBOOK_FULLNAME & """ ""from_xl"" >" & Chr(34) & LOG_FILE & Chr(34) & " 2>&1 &")
Res = system(RunCommand & """" & WORKBOOK_FULLNAME & """ ""from_xl""" & " " & Chr(34) & ToPosixPath(Application.Path) & "/" Application.Name & Chr(34) & ">" & Chr(34) & LOG_FILE & Chr(34) & " 2>&1 &")
End If
' If there's a log at this point (normally that will be from the Shell only, not Python) show it and reset the StatusBar
On Error Resume Next
Expand Down

0 comments on commit ed05d25

Please sign in to comment.