ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to read filesystem shortcut attributes (https://www.excelbanter.com/excel-programming/364419-how-read-filesystem-shortcut-attributes.html)

jdawson[_3_]

How to read filesystem shortcut attributes
 

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.


--
jdawson
------------------------------------------------------------------------
jdawson's Profile: http://www.excelforum.com/member.php...o&userid=32198
View this thread: http://www.excelforum.com/showthread...hreadid=552398


PaulD

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



jdawson[_5_]

How to read filesystem shortcut attributes
 

Thank you very much. It looks great. :) I will give it a try.


--
jdawson
------------------------------------------------------------------------
jdawson's Profile: http://www.excelforum.com/member.php...o&userid=32198
View this thread: http://www.excelforum.com/showthread...hreadid=552398



All times are GMT +1. The time now is 06:35 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com