Run Python method with args from VBA?

pheidlauf

Registered User.
Local time
Today, 01:02
Joined
Jun 5, 2013
Messages
42
I have a python script "runAll" that takes two arguments: processID (the primary key of one table as a string) and a filename (a full file name path as a string).

Is it possible to run a python method with arguments from inside a VBA script (activated by a button press)? If so, could you please provide a generic example of what the code would look like?

My python script is called XMLGenerator.py, and the method I want to run is called runAll(processID,filename).
 
As with all scripting languages you can run a function from command line so first of all go to command line and run the script. Once you're successful with that, use the same command line switches and call it using the Shell() function from within Access.
 
I think that the Shell command is definitely the right idea. I have a batch file (shown below) that opens the file I need, but I want to run that straight from the shell command without needing the batch file.

Code:
ssh user@hostname python /home1/username/Projects/importantScript.py ARG & pause
The value "ARG" will be determined by the currently viewed record in the MS Access database, which is accessed in VBA as "Me.processID". The "& pause" is in the bat file simply for testing purposes.

I've tried pasting this into a VBA method as:

Code:
Call Shell("ssh user@hostname python /home1/username/Projects/importantScript.py " & Me.processID & " & pause")

However, this VBA method does not work. What should I do to make this work? Is it possible? If not, what would be the next best way of solving this problem? Outside of VBA I have no idea how to feed an argument into a batch file.
 
Google gives 91,700,000 hits on "does not work". Which one applies?
 
Yes, please be more concise next time.

I've uploaded a simple example.
 

Attachments

Users who are viewing this thread

Back
Top Bottom