Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Relative Path to a Folder Heliocracy Excel Discussion (Misc queries) 3 October 3rd 07 04:28 PM
How to List the names of the subfolders present in the folder (path of folder is given in the textbox by user ) divya Excel Programming 3 November 30th 06 11:34 AM
Setting a path to a folder Boots Excel Discussion (Misc queries) 2 August 10th 06 02:14 PM
Finding the Path to the Program Files Folder JGS[_2_] Excel Programming 2 December 12th 05 09:16 AM
Get Folder Path RNM[_2_] Excel Programming 1 August 8th 04 03:19 AM


All times are GMT +1. The time now is 07:23 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"