Solved

Shell Code Needs a Tweak Excel 07 VBA Browse to folder

Posted on 2013-01-26
9
261 Views
Last Modified: 2013-02-11
Sub OpenFolderRequest()
Dim sPath As String

sPath = "C:\HospImports"

retVal = Shell("explorer.exe " & sPath, vbNormalFocus)

End Sub

Open in new window


The code works great. Now, I want the spath to instead be a folder like:

\\mynetwork\folder & range(d4).value

I can get the \\mynetwork\folder to work great. It doesn't like the rest, which is just a folder name that resides in cell D4.
0
Comment
Question by:Dreamboat
  • 6
  • 3
9 Comments
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 38822093
You should have something like

"\\mynetwork\folder" & range(d4).value

or

"\\mynetwork\folder\" & range(d4).value

depending whether D4 has a preceding \ or not
0
 
LVL 22

Author Comment

by:Dreamboat
ID: 38826444
The following just takes me to Documents, a/k/a C:\Users\atroy\Documents:

Sub OpenFolderRequest()
Dim sPath As String

sPath = "\\MyNetworkPath\myfolder\" & Range("d4").Value

retVal = Shell("explorer.exe " & sPath, vbNormalFocus)

End Sub

Open in new window

0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 38826502
What else do you want it to do?
0
 
LVL 22

Author Comment

by:Dreamboat
ID: 38829615
I want it to take me to the folder in the sPath, which is a network folder.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 22

Author Comment

by:Dreamboat
ID: 38846776
Anybody?
0
 
LVL 22

Author Comment

by:Dreamboat
ID: 38870735
I've requested that this question be deleted for the following reason:

No solution provided. The person who did respond didn't seem to pay attention to the fact that I needed a specific location.
0
 
LVL 43

Accepted Solution

by:
Saqib Husain, Syed earned 500 total points
ID: 38870736
Many apologies for disappearing. I just lost track of this.

This code is working just fine with me. You might have had an incorrect spelling or something. I have introduced this debug.print line which prints the path in the immediate window. Copy that path and paste it in the explorer address bar. This will help you pick up why it is not working.

I am objecting to the delete request so that you get a chance to test this. If you still want to delete this you can delete it again.


Sub OpenFolderRequest()
Dim sPath As String

sPath = "\\KASHIF-PC\" & Range("d4").Value

Debug.Print sPath

retVal = Shell("explorer.exe " & sPath, vbNormalFocus)

End Sub

Open in new window

0
 
LVL 22

Author Comment

by:Dreamboat
ID: 38871450
Great! Will try it Monday.
0
 
LVL 22

Author Closing Comment

by:Dreamboat
ID: 38877593
Woohoo!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now