+ Reply to Thread
Results 1 to 6 of 6

Running a Python Script from Excel VBA

  1. #1
    Registered User
    Join Date
    02-04-2018
    Location
    Canberra, Australia
    MS-Off Ver
    2013
    Posts
    74

    Running a Python Script from Excel VBA

    Hi All,

    I want to be able to invoke a Python script using VBA. With the following code I'm getting the following error:

    Method 'Run' of object 'IWshShell3' failed


    Please Login or Register  to view this content.

    Any help would be appreciated.

    Cheers

    Dean

  2. #2
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Running a Python Script from Excel VBA

    You could use Shell().

    Maybe:
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    02-04-2018
    Location
    Canberra, Australia
    MS-Off Ver
    2013
    Posts
    74

    Re: Running a Python Script from Excel VBA

    Thanks Kenneth,

    That has got rid of the error.

    Now I can see a CMD prompt flash open and close but doesn't seem to be running the Python script

    Help is appreciated

    Cheers

    Dean

  4. #4
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Running a Python Script from Excel VBA

    You can use /C to close the shell or /K to keep it open so you can see what happened.

    e.g.
    Please Login or Register  to view this content.
    When working, you can use vbHide. If you need it to wait to finish, there are shellwait routines.

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Running a Python Script from Excel VBA

    Dean

    What happens if you open a command window and manually try and run the string produced by this?
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  6. #6
    Registered User
    Join Date
    01-28-2021
    Location
    New York, NY
    MS-Off Ver
    2013
    Posts
    1

    Re: Running a Python Script from Excel VBA

    I am having the same problem. Is anyone able to help? Same syntax as Dean McK

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Ms Excel 2003 running a script
    By satpalbhullar87 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-24-2013, 02:30 AM
  2. call a python script from excel vba
    By sheffieldlad in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-28-2013, 07:11 PM
  3. Help!? Running/Re-running a SQL Script through Excel (easily?)
    By KOOOP in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-11-2013, 02:27 PM
  4. Running a Ruby script when excel is opened
    By booo in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-26-2011, 11:55 AM
  5. Running an Excel add-in from an external script
    By boomshanka9000 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-11-2009, 09:38 PM
  6. Running vbs script from an excel macro
    By freekrill in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-26-2008, 01:36 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1