[Python] Run and execute a Python script from VBA [duplicate]

Discussão em 'Python' iniciado por Stack, Maio 23, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to run a Python script from my VBA module. I've tried pretty much every example I've seen on the Internet and so far didn't have any luck.

    In the VBA module, I also run a .bat file, and it works perfectly:

    batchname = "U:\Backup Bat File.bat"

    Shell batchname, vbNormalFocus


    Next, I need to run the Python script, which is located in the same folder as the Excel file.

    Right now, I'm trying out this:

    Dim Ret_Val

    Dim args

    args=Activeworkbook.Path & "\beps_output.py"

    Ret_Val = Shell("C:\python34\python.exe" & args, vbNormalFocus)


    It doesn't error out, but nothing happens. I'm a little confused at what the "Ret_Val" (return value?) does here, and why it isn't running.

    Continue reading...

Compartilhe esta Página