ShellExecute

ShellExecute

Postby driessen » Wed Dec 09, 2009 2:07 pm

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  Expand view
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. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1417
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: ShellExecute

Postby Jack » Wed Dec 09, 2009 6:25 pm

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)
Jack
 
Posts: 283
Joined: Wed Jul 11, 2007 11:06 am

Re: ShellExecute

Postby Antonio Linares » Wed Dec 09, 2009 9:43 pm

Michel,

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

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41705
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: ShellExecute

Postby driessen » Thu Dec 10, 2009 10:25 am

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. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1417
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: ShellExecute

Postby anserkk » Thu Dec 10, 2009 10:28 am

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

Regards
Anser
User avatar
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: ShellExecute

Postby driessen » Thu Dec 10, 2009 10:47 am

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. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1417
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: ShellExecute

Postby Patrizio » Thu Dec 10, 2009 11:04 am

Driessen, http://msdn.microsoft.com/en-us/library/bb762153(VS.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  Expand view
shellexecute(,"open","winword.exe","LETTER.DOC /MMACRO")
Patrizio
 
Posts: 90
Joined: Wed Nov 07, 2007 8:56 am
Location: Italy

Re: ShellExecute - now it is solved

Postby driessen » Thu Dec 10, 2009 4:58 pm

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. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1417
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Maurizio and 47 guests