pythonvbaoutlookshellexecute

Running python script using Outlook VBA


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 Management\Exstream_Reconciliation.py"

Shell(Path)

End Sub

Solution

  • Ok this is the solution for anyone looking

    Sub RunPyFileFromMacroViaCmd()
        Dim Path As String
        Dim filepath As String
        filepath = """C:\Doc Management\Exstream_Reconciliation.py"""
        Path = "cmd /k" & filepath
        Shell (Path)
    End Sub