FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour ShellExecute
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
ShellExecute
Posted: Wed Dec 09, 2009 02: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 (fw): Select all Collapse
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. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 300
Joined: Wed Jul 11, 2007 11:06 AM
Re: ShellExecute
Posted: Wed Dec 09, 2009 06: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)

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: ShellExecute
Posted: Wed Dec 09, 2009 09:43 PM

Michel,

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

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Re: ShellExecute
Posted: 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.

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Re: ShellExecute
Posted: 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

Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Re: ShellExecute
Posted: 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. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 90
Joined: Wed Nov 07, 2007 08:56 AM
Re: ShellExecute
Posted: 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 (fw): Select all Collapse
shellexecute(,"open","winword.exe","LETTER.DOC /MMACRO")
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Re: ShellExecute - now it is solved
Posted: Thu Dec 10, 2009 04: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. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Continue the discussion