View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
John John is offline
external usenet poster
 
Posts: 2,069
Default Registry Default File Location Prevents Shell

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\CUR RENTVERSION\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.