Python Forum
Equivalent Python code from VBA
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Equivalent Python code from VBA
#1
Hi Guys

Refer to the below code which is developed on Excel VBA, the code essentially opens Space Gass and passes the text to the Space Gass.
What would the equivalent be on Python?

I currently have managed to open Space Gass from Python using "subprocess.call()"

    Dim strSGProgram As String
    strSGProgram = """" & "C:\Program Files (x86)\SPACE GASS 14\sgwin.exe" & """"
    Dim strSGScript As String
    strSGScript = " -s " & """" & "c:\temp\SGScriptDemo\Save and close script.txt" & """"
    Call Shell(strSGProgram & strSGScript, vbMinimizedNoFocus)
Reply
#2
I guess you could do something like this:

import subprocess

strSGProgram = r'"C:\Program Files (x86)\SPACE GASS 14\sgwin.exe"'
strSGScript = r' -s "c:\temp\SGScriptDemo\Save and close script.txt"'

command = strSGProgram + strSGScript
subprocess.run(command, creationflags=subprocess.CREATE_NO_WINDOW, shell=True)
Edit: updated to subprocess.run() since subprocess.call() is deprecated.
Mishal0488 likes this post
Reply
#3
happy wheels
Thank you, that resolved it
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  PySpark Equivalent Code cpatte7372 0 1,269 Jan-14-2022, 08:59 PM
Last Post: cpatte7372
  Python C++ Template Equivalent deanhystad 7 3,413 May-04-2021, 07:45 PM
Last Post: deanhystad
  Hi Guys, please help me to write SAS macro parameter equivalent code in Python Manohar9589 2 2,611 Jun-14-2020, 05:07 PM
Last Post: Larz60+
  python equivalent to MATLAB xcov chai0404 2 3,889 Apr-02-2020, 10:29 PM
Last Post: chai0404
  Python equivalent of Matlab code kwokmaster 1 3,462 Mar-25-2020, 10:14 PM
Last Post: j.crater
  Equivalent of 'bwareafilt' for Python Mighty 1 3,613 Feb-05-2020, 10:32 PM
Last Post: Marbelous
  Convert a mongo db scrip to python equivalent Herath 1 2,196 Aug-20-2019, 02:28 PM
Last Post: fishhook
  SAS Equivalent of Macro variable in Python AI_ML_Neophyte 4 11,673 Mar-29-2019, 08:14 AM
Last Post: FelixS
  Python equivalent to sed [solved] cygnus_X1 2 11,417 Sep-24-2018, 10:13 PM
Last Post: cygnus_X1
  equivalent commands saeed_balk 2 2,699 Sep-23-2018, 05:44 AM
Last Post: saeed_balk

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020