Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

referencing explorer.exe considering different OS's 1

Status
Not open for further replies.

AndyHorn

Technical User
Feb 12, 2003
49
0
0
GB
Hi,

How would I go about referencing windows explorer in VBA for a multi operating system environment? The problem being that explorer lives in C:\WINNT\ on Win2K and in C:\WINDOWS on WinXP.

The code I am currently using is:

Private Sub CmdOpenBrochureDir_Click()

On Error GoTo Err_CmdOpenBrochureDir_Click

Dim stAppName As String

stAppName = "C:\WINDOWS\explorer.exe S:\DirectoryName"
Call Shell(stAppName, 1)

Exit_CmdOpenBrochureDir_Click:
Exit Sub

Err_CmdOpenBrochureDir_Click:
MsgBox err.Description
Resume Exit_CmdOpenBrochureDir_Click

End Sub

I've tried replacing C:\WINDOWS\explorer.exe with, %SystemRoot%\explorer.exe, but it says file not found.

Any ideas?

Thanks
 
assuming that the path is already setup by the os itself, then surely just "explorer" would do...?

--------------------
Procrastinate Now!
 
Since Explorer.exe is in the system path all you need is for example

Shell "Explorer.exe C:\", vbMaximizedFocus

Hope this helps.
 
lol, you have to be on your toes in here...

--------------------
Procrastinate Now!
 
I though I'd sneak in while you were busy in TTUK, but you were still too quick [smile]
 
Indeed it was that simple Crowley16. Have a star.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top