Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Shell Code Needs a Tweak Excel 07 VBA Browse to folder

Posted on 2013-01-26
9
Medium Priority
?
324 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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
 
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 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

886 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