vba - Getting shell cmd output to Excel -
i have macro in vba (excel 2007). opens exe file entering hex value variable. exe gives output (also hex number). "shell" command , results saved txt file. write excel.
retval = shell("cmd.exe /c c:\aabb\app.exe 0x5110 > c:\aabb\output.txt", vbnormalfocus)
it complicated , time-consuming. prefer getting result straight excel, without intermediate file txt or similar.
when utilize output.xlsx output destination, file created , value written. cant read excel. see value when open xlsx notepad.
my questions are:
1) possible write result straight xlsx, target cell e.g. a10
2) why when utilize xlsx destination in shell command, can't open excel? gives error message of "file-format or file-extension not valid. info might corrupted".
i think can't shell object. can wshexec function stdout.readline(). have go reference , take "windows script host object model" can declare wshexec object. see method yourwshexecobject.stdout.readline().
to build wshexec : first declare wshshell object , build :
dim wshshellobject wshshell
dim wshexecobject wshexec
set wshshellobject = createoject("wscript.shell")
set wshexecobject = wshshellobject.exec("you .exe filename").
the stdout method read write in console. did .exe compilated c++.
hope helps
vba shell cmd output
No comments:
Post a Comment