[Python] Running Python script from VBA nothing happens, but when I run it from python.exe, it...

Discussão em 'Python' iniciado por Stack, Agosto 31, 2025.

  1. Stack

    Stack Membro Participativo

    I'm running Python scrpit from VBA. The result should be a filled cell in Exel file. I tried using this VBA command:

    RetVal = Shell("""C:\Python27\python.exe""" & " " & """M:\Analysis\PythonScripts\MySript.py""", vbHide)


    But nothing happens as the result. However, if I run this scipt from python.exe directly, it works fine. The cell in Excel file is filled with a value. Which brings me to conclusion that something is wrong with VBA code.

    Update

    Fragment of Python Script:

    ExcelApp = win32com.client.GetActiveObject("Excel.Application")
    wb = ExcelApp.Workbooks('File1.xlsm')
    sheet = wb.Worksheets(u'Result')
    cell = sheet.Range('B1')
    cell.Value = result

    Continue reading...

Compartilhe esta Página