View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default Open folder with code

SysRoot = Split(Environ(20), "=")(1)

You can't rely on the system root folder being the 20th item in
the Environment variables. On my machine, Environ(20) is the
Processor Identifier. Instead, use

SysRoot = Environ("SystemRoot")



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com





"NickHK" wrote in message
...
Damien,
Here's one way:
Private Sub CommandButton2_Click()
Dim SysRoot As String
SysRoot = Split(Environ(20), "=")(1)
Shell SysRoot & "\explorer.exe /e, G:", vbNormalFocus
End Sub

NickHK

"Damien" wrote in message
...
I need a coding solution to the following: I have a command
button on a

sheet
which is to open a Windows Explorer Directory. I have
previously used
hyperlinks to open and show the user with the following code
(with

button).

Range("V8").Select
Selection.Hyperlinks(1).Follow NewWindow:=False,
AddHistory:=True
Range("A1").Select
Application.ScreenUpdating = False

I was wondering if there is a better way to do without having
the

hyperlink.