ShellExecute

Post Reply
User avatar
driessen
Posts: 1239
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

ShellExecute

Post by driessen »

Hello,

I want to open a Word document without using OLE.
But I also want a macro to be executed.

Normally for opening a document and executing a macro MACRO you do :
WINWORD.EXE LETTER.DOC /MMACRO
Because I don't know the exact path of WINWORD.EXE, I want to use ShellExecute()

So I tried this code :

Code: Select all

ShellExecute(,"Open","LETTER.DOC","/MMACRO",,3)
The document is opened in Word, but the macro MACRO is not executed, although the 4th position is ment to add parameters.

What can I do to execute the macro in an automatic way ?

Thanks a lot in advance for any help.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
Jack
Posts: 249
Joined: Wed Jul 11, 2007 11:06 am

Re: ShellExecute

Post by Jack »

Michel,

Try with winexec .

lnf:="i:\Ret"+dtos(date())+substr(time(),1,2)+"h"+substr(time(),4,2)+".doc"
WinExec( "winword " + lnf )

Good luck .

Ph Jacquet (Belgium)
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: ShellExecute

Post by Antonio Linares »

Michel,

Have you tried with "//MMACRO" ? (notice the two //)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
driessen
Posts: 1239
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: ShellExecute

Post by driessen »

Antonio,

You are the greatest. The double backslash was the right solution.

(After EDIT : Sorry, the problem is not solved - see my new message)

Thank you very much.

To Philippe,

I also tried your WINEXEC proposal, but it doesn't work.

But thank you for your effort.
Last edited by driessen on Thu Dec 10, 2009 10:46 am, edited 1 time in total.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
User avatar
anserkk
Posts: 1280
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: ShellExecute

Post by anserkk »

Hi,
Can anybody explain, What is the difference between ShellExecute() and WinExec(). Is there any performance difference between the two ?

Regards
Anser
User avatar
driessen
Posts: 1239
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: ShellExecute

Post by driessen »

Sorry, Antonio, the problem was not solved.

the double backslash doesn't seem to be a solution.

Anyone any idea ?

Thanks.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
Patrizio
Posts: 90
Joined: Wed Nov 07, 2007 8:56 am
Location: Italy
Contact:

Re: ShellExecute

Post by Patrizio »

Driessen, http://msdn.microsoft.com/en-us/library ... S.85).aspx
lpParameters
[in] If lpFile specifies an executable file, this parameter is a pointer to a null-terminated string that specifies the parameters to be passed to the application. The format of this string is determined by the verb that is to be invoked. If lpFile specifies a document file, lpParameters should be NULL.
So, you can't pass parameter if you open a .doc.

But, if you open a exe you can, try this

Code: Select all

shellexecute(,"open","winword.exe","LETTER.DOC /MMACRO")
User avatar
driessen
Posts: 1239
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: ShellExecute - now it is solved

Post by driessen »

Patrizio,

Thank you very much for your help.

Your suggestion is working fine. My problem is solved.

Thank you, guys.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
Post Reply