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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to save a file when using shortcuts to browse to the folder? 1

Status
Not open for further replies.

Johnomill

Technical User
Dec 19, 2001
19
NL
I have a program which allows the user to save data to a location. My save-as-dialog shows 'real' folders but also shortcuts (.lnk). I use the file scripting object to check if the selected folder exists. When i select a shortcut (.lnk), fso.folderExists returns False. Is there a way to save a file using the shortcut OR is there way to determine what the pointing directory of the shortcut is??

best regards,

John


 
Yes! :)

this one did the job...

Private Function ExeFromLnk(ByVal LnkFileName As String) As String
Dim strTarget As String
Dim strShortFileName As String
Dim lnkShortcut As Object
Dim wshShell As Object
strShortFileName = String(255, " ") & Chr(0)
Call GetShortPathName(LnkFileName, strShortFileName, Len(strShortFileName))
MsgBox LnkFileName & vbLf & strShortFileName
Set wshShell = CreateObject("WScript.Shell")
Set lnkShortcut = wshShell.CreateShortcut(strShortFileName)
With lnkShortcut
strTarget = .TargetPath
End With
Set lnkShortcut = Nothing
Set wshShell = Nothing
ExeFromLnk = strTarget
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top