Opening Windows Explorer

L

Launchnet

The Below Macro Works, but I need a Macro that will open Windows Explorer
from Excel, displaying My Documents regardless of what Path Explorer is
located in. I have too many users to go thru and change for each person.

Can someone give me a hand - PLEASE.

Below is my current code that I have to change for each different path on
every computer.


Sub WindowsExplorer()
Shell "C:\WINDOWS\Explorer.exe /e,c:\Documents and Settings\default\My
Documents", vbNormalFocus
End Sub


I don't think that "Shell" can be used for this.

Thanks
Matt
 
R

Ron de Bruin

hi Launchnet

From this page
http://www.rondebruin.nl/folder.htm#3)

Try this macro

Sub GetSpecialFolder()
'Special folders are : AllUsersDesktop, AllUsersStartMenu
'AllUsersPrograms, AllUsersStartup, Desktop, Favorites
'Fonts, MyDocuments, NetHood, PrintHood, Programs, Recent
'SendTo, StartMenu, Startup, Templates

'Get Favorites folder and open it
Dim WshShell As Object
Dim SpecialPath As String

Set WshShell = CreateObject("WScript.Shell")
SpecialPath = WshShell.SpecialFolders("MyDocuments")
MsgBox SpecialPath
'Open folder in Explorer
Shell "explorer.exe " & SpecialPath, vbNormalFocus
End Sub
 
J

JW

Launchnet said:
The Below Macro Works, but I need a Macro that will open Windows Explorer
from Excel, displaying My Documents regardless of what Path Explorer is
located in. I have too many users to go thru and change for each person.

Can someone give me a hand - PLEASE.

Below is my current code that I have to change for each different path on
every computer.


Sub WindowsExplorer()
Shell "C:\WINDOWS\Explorer.exe /e,c:\Documents and Settings\default\My
Documents", vbNormalFocus
End Sub

Just drop the path from explorer.exe:

Sub WindowsExplorer()
Shell "Explorer.exe /e,c:\Documents and Settings\default\My
Documents", vbNormalFocus
End Sub
 
L

Launchnet via OfficeKB.com

Hi Ron . . .

Thanks for the suggestion. There are several problems which I came across so
far.
1. After opening 1st time and then changing the folder name that we want to
open,
it keeps opening to the name of the 1st folder and won't change folders.
2. We also want the entire C:\ path to be displayed.

Please see the other two replies to suggestions. I am going to post the last
reply right away.

Again, Thanks very much.

Matt@Launchnet
hi Launchnet

From this page
http://www.rondebruin.nl/folder.htm#3)

Try this macro

Sub GetSpecialFolder()
'Special folders are : AllUsersDesktop, AllUsersStartMenu
'AllUsersPrograms, AllUsersStartup, Desktop, Favorites
'Fonts, MyDocuments, NetHood, PrintHood, Programs, Recent
'SendTo, StartMenu, Startup, Templates

'Get Favorites folder and open it
Dim WshShell As Object
Dim SpecialPath As String

Set WshShell = CreateObject("WScript.Shell")
SpecialPath = WshShell.SpecialFolders("MyDocuments")
MsgBox SpecialPath
'Open folder in Explorer
Shell "explorer.exe " & SpecialPath, vbNormalFocus
End Sub
The Below Macro Works, but I need a Macro that will open Windows Explorer
from Excel, displaying My Documents regardless of what Path Explorer is
[quoted text clipped - 14 lines]
Thanks
Matt

--
Please take a look at www.openoursite.com Click on: "Keywords" and then
Click on "Matt's Story" and if you are a man, you should be very happy that
you read my story. God Bless for everyones help.

Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/excel-programming/200708/1
 
L

Launchnet via OfficeKB.com

Hi JW . . .

So far I have tested 3 suggested ways of doing this. So far, I have found no
problem with your suggestion. I still have to test it on several other
versions of Windows to be sure it works on all.

Thanks Very Much.

Matt@Launchnet
The Below Macro Works, but I need a Macro that will open Windows Explorer
from Excel, displaying My Documents regardless of what Path Explorer is
[quoted text clipped - 9 lines]
Documents", vbNormalFocus
End Sub

Just drop the path from explorer.exe:

Sub WindowsExplorer()
Shell "Explorer.exe /e,c:\Documents and Settings\default\My
Documents", vbNormalFocus
End Sub

--
Please take a look at www.openoursite.com Click on: "Keywords" and then
Click on "Matt's Story" and if you are a man, you should be very happy that
you read my story. God Bless for everyones help.

Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/excel-programming/200708/1
 
L

Launchnet via OfficeKB.com

Hi JW Again . . .
Just finished testing on XP, 98 and 95 and it works on all 3. I don't have
anyother versions of windows so we will fly with this.

Many Thanks

Matt@Launchnet
Hi JW . . .

So far I have tested 3 suggested ways of doing this. So far, I have found no
problem with your suggestion. I still have to test it on several other
versions of Windows to be sure it works on all.

Thanks Very Much.

Matt@Launchnet
[quoted text clipped - 8 lines]
Documents", vbNormalFocus
End Sub

--
Please take a look at www.openoursite.com Click on: "Keywords" and then
Click on "Matt's Story" and if you are a man, you should be very happy that
you read my story. God Bless for everyones help.

Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/excel-programming/200708/1
 
S

Shah Shailesh

Try this,


Shell "Explorer.exe /e," & Mid(Environ(27), 13) & "\My Documents",
vbNormalFocus


This should work regardless of Path of Explorer & My document for Window XP.


Regards,
Shailesh Shah
http://in.geocities.com/shahshaileshs/
(Free addins Office Menu-2003 for Office-2007)
 
L

Launchnet via OfficeKB.com

Hi Shah . . .

Tried, but I get the following error message: The path 'TATION2\My
Documents' does not exist or is not a directory.

Matt

Shah said:
Try this,

Shell "Explorer.exe /e," & Mid(Environ(27), 13) & "\My Documents",
vbNormalFocus

This should work regardless of Path of Explorer & My document for Window XP.

Regards,
Shailesh Shah
http://in.geocities.com/shahshaileshs/
(Free addins Office Menu-2003 for Office-2007)
The Below Macro Works, but I need a Macro that will open Windows Explorer
from Excel, displaying My Documents regardless of what Path Explorer is
[quoted text clipped - 14 lines]
Thanks
Matt
 
S

Shah Shailesh

What window version it is?

What you get when using Environ("userprofile") from different window
version.

Check this function as under from vba code module or debug window.

msgbox Environ("userprofile")

or

debug.print Environ("userprofile")


From your error message you can try as under only for your Window Version.

Shell "Explorer.exe /e," & Mid(Environ(27), 20) & "\My Documents",
vbNormalFocus


I suggest this because user may have installed windows other then C drive
and it depends upon User Profile and also Window Version for the path of My
Document.



Regards,
Shailesh Shah
http://in.geocities.com/shahshaileshs/
(Free addins Office Menu-2003 for Office-2007)



Launchnet via OfficeKB.com said:
Hi Shah . . .

Tried, but I get the following error message: The path 'TATION2\My
Documents' does not exist or is not a directory.

Matt

Shah said:
Try this,

Shell "Explorer.exe /e," & Mid(Environ(27), 13) & "\My Documents",
vbNormalFocus

This should work regardless of Path of Explorer & My document for Window
XP.

Regards,
Shailesh Shah
http://in.geocities.com/shahshaileshs/
(Free addins Office Menu-2003 for Office-2007)
The Below Macro Works, but I need a Macro that will open Windows
Explorer
from Excel, displaying My Documents regardless of what Path Explorer is
[quoted text clipped - 14 lines]
Thanks
Matt
 
S

Shah Shailesh

Hi Matt,

If you want to use Ron's macro then use as under.

Sub GetSpecialFolder()
Dim WshShell As Object
Dim SpecialPath As String
Set WshShell = CreateObject("WScript.Shell")
SpecialPath = WshShell.SpecialFolders("MyDocuments")
Shell "explorer.exe /e, " & SpecialPath, vbNormalFocus
End Sub


To use Environ function, use it as under.


Shell "Explorer.exe /e," & Environ("userprofile") & "\My Documents",
vbNormalFocus


Regards,
Shailesh Shah
http://in.geocities.com/shahshaileshs/
If You Can't Excel with Talent, Triumph with Effort.

http://in.geocities.com/shahshaileshs/menuaddins
(Free addins old\classic Office Menu-2003 for Office-2007)




Shah Shailesh said:
What window version it is?

What you get when using Environ("userprofile") from different window
version.

Check this function as under from vba code module or debug window.

msgbox Environ("userprofile")

or

debug.print Environ("userprofile")


From your error message you can try as under only for your Window Version.

Shell "Explorer.exe /e," & Mid(Environ(27), 20) & "\My Documents",
vbNormalFocus


I suggest this because user may have installed windows other then C drive
and it depends upon User Profile and also Window Version for the path of
My Document.



Regards,
Shailesh Shah
http://in.geocities.com/shahshaileshs/
(Free addins Office Menu-2003 for Office-2007)



Launchnet via OfficeKB.com said:
Hi Shah . . .

Tried, but I get the following error message: The path 'TATION2\My
Documents' does not exist or is not a directory.

Matt

Shah said:
Try this,

Shell "Explorer.exe /e," & Mid(Environ(27), 13) & "\My Documents",
vbNormalFocus

This should work regardless of Path of Explorer & My document for Window
XP.

Regards,
Shailesh Shah
http://in.geocities.com/shahshaileshs/
(Free addins Office Menu-2003 for Office-2007)

The Below Macro Works, but I need a Macro that will open Windows
Explorer
from Excel, displaying My Documents regardless of what Path Explorer is
[quoted text clipped - 14 lines]
Thanks
Matt
 

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