![]() |
Finding the path of a folder
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 |
Finding the path of a folder
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 -- Jim "Anne Schouten" wrote in message ... 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 |
Finding the path of a folder
Thank you Jim.
I think I can work it out now. Thanks, Anne "Jim Rech" wrote in message ... 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 -- Jim "Anne Schouten" wrote in message ... 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 |
Finding the path of a folder
Hi Jim.
I can not get TargetPath. Do I need to set a Reference? -- Best Regards Joergen Bondesen "Jim Rech" skrev i en meddelelse ... 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 -- Jim "Anne Schouten" wrote in message ... 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 |
All times are GMT +1. The time now is 08:41 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com