Solved

Shell Code Needs a Tweak Excel 07 VBA Browse to folder

Posted on 2013-01-26
9
251 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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

708 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

15 Experts available now in Live!

Get 1:1 Help Now