I wish to communicate with MS applications and/or system calls. For instance, I have want my c++ program to execute Word for a user selected document and execute a macro. How can I issue a DOS command (i.e. winword.exe <document> /m<macro>)? Any ideas? Any place I can find examples?
Wayne
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hmmm, I guess I am going to have to start signing my posts differently.
Wayne
oops, I'll go to one of my first screen names
dockeen
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2002-11-14
Hi Wayne,
I've included a section of code from one of my programs. This is from a Windows app
where the user selects a pdf file from a listbox. Once the pdf file is selected the program
then sends it to the ShellExecute function which passes the pdf to Adobe. Something
similar should work with a doc file in winword.
case ID_LISTBOX2:
if (CodeNotify == LBN_SELCHANGE)
{
HINSTANCE ShellInst;
int ShellRetInfo;
char PathBuf[100];
char CurDir[100];
GetCurrentDirectory(100,CurDir);
DlgDirSelectEx(hwnd,PathBuf,100,ID_LISTBOX2);
ShellInst = ShellExecute(hwnd,"open",PathBuf,NULL,CurDir,SW_MAXIMIZE);
if (!ShellInst)
MessageBox (NULL,"You must have Adobe Reader installed to view PDF files!","ERROR!!!", 0);
}
break;
hope this helps,
Dale
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I wish to communicate with MS applications and/or system calls. For instance, I have want my c++ program to execute Word for a user selected document and execute a macro. How can I issue a DOS command (i.e. winword.exe <document> /m<macro>)? Any ideas? Any place I can find examples?
Wayne
I thought you could use <stdlib.h> and use the "system()" function to solve your problem.
'system("dir")' would display contents of you current working directory.
Can "winword.exe" accept arguments and switches from command line?
:-\ Nhan
how do you extract enviroment varibles like "HOMEDRIVE", "windir", "SystemRoot" inside a program?
I just thought up of a way of doing this, but i'm sure there is a better way of doing it.
-make a "system()" call to call a batch file to echo the values
-redirect the output to a file
-read the file to obtain the enviroment varibles
Someone show me a better way of doing this.
:-)
Nhan
Hmmm, I guess I am going to have to start signing my posts differently.
Wayne
oops, I'll go to one of my first screen names
dockeen
Hi Wayne,
I've included a section of code from one of my programs. This is from a Windows app
where the user selects a pdf file from a listbox. Once the pdf file is selected the program
then sends it to the ShellExecute function which passes the pdf to Adobe. Something
similar should work with a doc file in winword.
case ID_LISTBOX2:
if (CodeNotify == LBN_SELCHANGE)
{
HINSTANCE ShellInst;
int ShellRetInfo;
char PathBuf[100];
char CurDir[100];
GetCurrentDirectory(100,CurDir);
DlgDirSelectEx(hwnd,PathBuf,100,ID_LISTBOX2);
ShellInst = ShellExecute(hwnd,"open",PathBuf,NULL,CurDir,SW_MAXIMIZE);
if (!ShellInst)
MessageBox (NULL,"You must have Adobe Reader installed to view PDF files!","ERROR!!!", 0);
}
break;
hope this helps,
Dale