Solved

Shell Code Needs a Tweak Excel 07 VBA Browse to folder

Posted on 2013-01-26
9
273 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
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…

803 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