Hello all,
I am a newbie with VBA, but I have picked up a few tricks from posting here several times and reading various forums, so I thought I'd try to get help once again.
To give you context, Col A on my excel sheet has values with the following format: "xxxx-XXXX". The "xxxx-" is irrelevant but the folder will be named "XXXX". Ultimately, I want to be able to select a cell in Col A, use a shortcut like Ctrl+Shift+Q or something and open the corresponding folder. But, before I get into depth of my end goal, I need working VBA to get the folder open.
From what I was able to gather from forums, I have come up with:
Sub testOpenFolder()
Dim strFolder As String
Dim k As Integer
k = Right(ActiveCell, 4)
strFolder = "\\SERVER\test\" & k
Call Shell("explorer.exe" & strFolder, vbNormalFocus)
End Sub
As it stands now, I get error 53 / file not found on the line just before End Sub. I tried using the VBA to open a folder on my C: drive instead of the network, but got the same error on the same line.
Can anyone help me out? The forums I used as a reference all used static folder locations, so maybe I defined my dynamic folder location incorrectly (but the debugger didn't error out on that line, so not sure)? Did I use mess up integrating the "ActiveCell" function with the "RIGHT" formula to define variable k?
Or maybe my error is more basic:
Can VBA open a folder on the network and not on the actual machine it was run from? Can VBA open a folder using a defined variable for the folder location?
Any help would be greatly appreciated. Thank you for taking the time to review my code and read my questions,
-S
Bookmarks