Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Relative Path to a Folder | Excel Discussion (Misc queries) | |||
How to List the names of the subfolders present in the folder (path of folder is given in the textbox by user ) | Excel Programming | |||
Setting a path to a folder | Excel Discussion (Misc queries) | |||
Finding the Path to the Program Files Folder | Excel Programming | |||
Get Folder Path | Excel Programming |