word vba - vba WScript.Shell run .exe file with parameter -
word vba - vba WScript.Shell run .exe file with parameter -
i running vba macro word 2013. i'm trying run executable file requires argument/parameter of filename. example, c:\myfilefilter.exe filetobefiltered.htm utilize shell run because want vba code wait until executable finished running before resuming vba code. lastly 3 lines in code below examples of of syntax have tried not work. think problem space between executable programme , file filters. know right syntax or way wait executable programme finish. if need more info, please ask.
dim wsh object set wsh = vba.createobject("wscript.shell") dim waitonreturn boolean: waitonreturn = true dim windowstyle integer: windowstyle = 1 dim errorcode integer dim strprogramname string dim strmyfile string phone call shell("""" & strprogramname & """ """ & strmyfile & """", vbnormalfocus, waitonreturn""") wsh.run(strprogramname & """ """ & filetofilterb & """", vbnormalfocus, waitonreturn") wsh.run "chr(34)strprogramnamechr(34)strmyfile", waitonreturn
==================== code below works. after strcmd, first number 1 boolean toogle 1 displays dos box , 0 hides dos box, sec number similar, 1 waits programme finish before continuing vba code, 0 not wait.
strcmd = smyprogram + " " + smyfile dim wsh object set wsh = vba.createobject("wscript.shell") wsh.run strcmd, 1, 1
you seek this. works me.
const batchfilename = "p:\export.bat"
dim wsh object
set wsh = vba.createobject("wscript.shell") dim waitonreturn boolean: waitonreturn = true dim windowstyle integer: windowstyle = 1 wsh.run batchfilename, windowstyle, waitonreturn kill batchfilename
vba word-vba wscript
Comments
Post a Comment