How to read filesystem shortcut attributes

  • Thread starter Thread starter jdawson
  • Start date Start date
J

jdawson

I would like Excel to read the attributes of a file system shortcut and
see what folder or file that the shortcut points to.

I posted a similar question several weeks earlier and had no
responses.

If anyone can help, thanks.
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top