Registry Default File Location Prevents Shell

J

JOHN

In my installation of Excel (Office 2003) a default setting (Tools Options
General - Default File Location) seems to be set from a registry key
(HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\WINDOWS\CURRENTVERSION\EXPLORER\DocFolderPaths).

This setting is set every time my machine is rebooted even if you delete the
path in Excel via Tools Options General. If you delete the registry key then
this setting is empty.

The problem I have is that this setting seems to prevent the Shell command
from working properly. I attach the code below. i.e If I run the code with a
file path specified in the Default File Location the code does not run (i.e
launch the specified exe) if this setting is clear then the code runs fine.

The code

Public Sub ShellAndWait(ByVal PathName As String, Optional WindowState)
Dim hProg As Long
Dim hProcess As Long, ExitCode As Long
If IsMissing(WindowState) Then WindowState = 1
hProg = Shell(PathName, WindowState)
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, False, hProg)
Do
GetExitCodeProcess hProcess, ExitCode
DoEvents
Loop While ExitCode = STILL_ACTIVE
End Sub


Any ideas would be much appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top