View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
PaulD PaulD is offline
external usenet poster
 
Posts: 92
Default How to read filesystem shortcut attributes


"jdawson" wrote in
message ...
:
: I would like Excel to read the attributes of a file system shortcut and
: see what folder or file that the shortcut points to.
:

Here is a quick version for .lnk files, it would need to be modified
slightly for .url links
I hardcoded in a shortcut from my desktop to the ShortcutPath variable,
replace it with the shortcut you are using. I also used late binding for
reference compatibility, you could early bind it and set a reference to
Windows Script Host Object Model.

Public Sub ShortcutTarget()
Dim Shell As Object
Dim ShortcutPath As String
Dim FileShortcut As Object

Set Shell = CreateObject("WScript.Shell")
ShortcutPath = "C:\Documents and Settings\pauld\Desktop\fastener.xls.lnk"
Set FileShortcut = Shell.CreateShortcut(ShortcutPath)
MsgBox FileShortcut.TargetPath
End Sub

Paul D