Running python script using Outlook VBA
Question:
Im trying to run a python script using Outlook Vba. When I run the below code. A python icon appears in the taskbar for a second and disappears. When in fact it should open a dialogue box and prompt me to enter folder name. After which it should run the rest of the script as usual.
Please help me run this script from outlook as I regularly do by double clicking the .py file.
Sub runpythonscript()
Dim Path As String
Path = "python C:Doc ManagementExstream_Reconciliation.py"
Shell(Path)
End Sub
Answers:
VBA (nor Outlook) doesn’t provide anything for debugging such cases. The best what you could do is to add log statements to the python script where you could output everything what happens in the code. Analyzing log files you will be able to figure the cause of the problem.
You have a space in the file name. It must be quoted.
Ok this is the solution for anyone looking
Sub RunPyFileFromMacroViaCmd()
Dim Path As String
Dim filepath As String
filepath = """C:Doc ManagementExstream_Reconciliation.py"""
Path = "cmd /k" & filepath
Shell (Path)
End Sub
Im trying to run a python script using Outlook Vba. When I run the below code. A python icon appears in the taskbar for a second and disappears. When in fact it should open a dialogue box and prompt me to enter folder name. After which it should run the rest of the script as usual.
Please help me run this script from outlook as I regularly do by double clicking the .py file.
Sub runpythonscript()
Dim Path As String
Path = "python C:Doc ManagementExstream_Reconciliation.py"
Shell(Path)
End Sub
VBA (nor Outlook) doesn’t provide anything for debugging such cases. The best what you could do is to add log statements to the python script where you could output everything what happens in the code. Analyzing log files you will be able to figure the cause of the problem.
You have a space in the file name. It must be quoted.
Ok this is the solution for anyone looking
Sub RunPyFileFromMacroViaCmd()
Dim Path As String
Dim filepath As String
filepath = """C:Doc ManagementExstream_Reconciliation.py"""
Path = "cmd /k" & filepath
Shell (Path)
End Sub