I am trying to generate an .exe file an integrate it with my Excel VBA code.
I am using CodeBlocks IDE to generate the .exe, Excel2013 and CodeBlocks2013 versions on a 64-bit computer.
I created my CodeBlocks project (my_program1) in two ways i.e. "Console Application" and "Empty Project", and compiled the project successfully in both the cases.
When I run the .exe from command prompt, I am able to get desired results in both cases.
However, when I run the same commands by invoking the .exe from my VBA code, it shows no results i.e. blank.
I printed out the commands which my VBA code executes and found that they as same as the commands which i use in the command prompt (correct file paths etc.)
When I execute the command via command prompt i.e.
D:my_program1.exe list, i get the names in my command prompt.
Following is part of my VBA code:
//list = command which my_program accepts and returns list of names
command_for_name = ActiveWorkbook.Path & "my_program1.exe list"
//here, message box shows D:my_program1.exe list
MsgBox command_for_name
//names returned by my_program1 to be seen in cell F7
Cells(7, "f").Value = CreateObject("WScript.Shell").Exec("cmd.exe /S /C" & command_for_name).StdOut.ReadAll
However, Cell F7 is blank.
I even tried.
MsgBox CreateObject("WScript.Shell").Exec("cmd.exe /S /C" & command_for_name).StdOut.ReadAll
however, the message box is also blank.
What should I change to get the .exe to work with my VBA code?
Thanks a lot in advance!
question from:
https://stackoverflow.com/questions/65874313/how-to-run-createobject-in-vba-code-with-exe-generated-in-codeblocks-ide 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…