Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I want to read targetPath of a shortcut with VBA 97 1

Status
Not open for further replies.

ThinLizzy

Programmer
May 30, 2002
12
NL
Hello,

I want to reed the path of a shortcut file in a
directory, see beneth:

Public Function TargetPathOfShortCut() As String
Dim strLink As String

strLink = Dir("c:\*.LNK") ' Return first *.LNK file
' (this link to another File
' for instance mylink.LNK
' What I want to know is to
' which file this link
' is pointing
' Something like:

TargetPathOfShortCut = _
TheFunctionOrObjectIamLookingFor(strLink)

End Function

I found a control on the Internet but it only worked
with VB6. I would like to see the code of this control!

Does anyone knows a solution for this ?
It is realy fustrating problem for me....
 
Private Function GetShortcutTarget(strShortcut As String) As String
Dim wshell As Object
Set wshell = CreateObject("wscript.Shell")
On Error Resume Next ' skip if shortcut does not exist
GetShortcutTarget = wshell.CreateShortcut(strShortcut).TargetPath
On Error GoTo 0
End Function
 
Thanks you very much strongm.
It worked on VBA for word 97 to !!!
After serveral days of searching finally a
function that really works, THANKS !!!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top