Finding the path of a folder

  • Thread starter Thread starter Anne Schouten
  • Start date Start date
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
 
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
 
Back
Top