• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 355
  • Last Modified:

Shell Code Needs a Tweak Excel 07 VBA Browse to folder

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
Anne Troy
Asked:
Anne Troy
  • 6
  • 3
1 Solution
 
Saqib Husain, SyedEngineerCommented:
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
 
Anne TroyEast Coast ManagerAuthor Commented:
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
 
Saqib Husain, SyedEngineerCommented:
What else do you want it to do?
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Anne TroyEast Coast ManagerAuthor Commented:
I want it to take me to the folder in the sPath, which is a network folder.
0
 
Anne TroyEast Coast ManagerAuthor Commented:
Anybody?
0
 
Anne TroyEast Coast ManagerAuthor Commented:
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
 
Saqib Husain, SyedEngineerCommented:
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
 
Anne TroyEast Coast ManagerAuthor Commented:
Great! Will try it Monday.
0
 
Anne TroyEast Coast ManagerAuthor Commented:
Woohoo!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

  • 6
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now