Finding the path of a folder

A

Anne Schouten

With vba I made a menu which shows all the templates in the folder
C:\Personal
The templates in subfolders are shown as well.

So far everything went well.
The problem is that in this template folder are also shortcut folders.
How do I show the templates in the folder to which this shortcut refers to?
So I need the path to this folder, but I do not know how to get this path.

Thanks Anne
 
J

Jim Rech

You can get the target of a shortcut like this:

Sub DemoShortcutTarget()
Dim FName As String
FName = "C:\Link.lnk"
If LCase(Right(FName, 4)) = ".lnk" Then
MsgBox ShortcutTarget(FName)
End If
End Sub

Function ShortcutTarget(SCFilename As String) As String
Dim wsh As Object
Dim SC As Object
Set wsh = CreateObject("WScript.Shell")
''Next gets existing shortcut, otherwise creates it
Set SC = wsh.CreateShortcut(SCFilename)
ShortcutTarget = SC.TargetPath
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top