PDA

View Full Version : problems using the Shell() function



neok71
08-20-2007, 02:41 AM
Hi,

I have problems using the Shell() function. I would like to run a .exe program located in a different hard disk than my excel. This program creates a .xml file from some inputs you enter in a windows shell that opens when you run the program. The problem I have is that when I double click the .exe it creates the .xml file in the folder I want (the folder where the .exe is located) but when i run the excel macro whith the Shell() function it creates the .xml file in an other folder. What can I do?

rory
08-20-2007, 03:24 AM
You might try using the ShellExecute API funciton and passing it the default directory - see here (http://support.microsoft.com/kb/238245) for details - though I can't think why it would work with a simple double-click but not with Shell; what is the command you are using?

neok71
08-20-2007, 03:55 AM
Thank you very much!!! The ShellExecute API funciton does what I want (but I don't understand what's hwnd = apiFindWindow("OPUSAPP", "0"), I wrote that and it works so its ok for me).

thank you again.

rory
08-20-2007, 04:18 AM
'OpusApp' is the class name for Word so you don't actually need that line here - you can just use 0 in place of hWnd.

PS It would be 'XLMAIN' for Excel but you can use Application.hWnd in Excel 2002 and up (I can't recall if it was available in 2000 or prior)

neok71
08-20-2007, 06:11 AM
Oks, thank you very much.