Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 246
Default Extract Target path from a shortcut

I know how to add a target path to a created shortcut:

Dim WSHShell As Object
Dim MyShortcut As Object

Set WSHShell = CreateObject("WScript.Shell")
Set MyShortcut = WSHShell.CreateShortcut(pathwayhere & ".lnk")

With MyShortcut
.targetpath = targetpathwayhere
.Save
End With

.........but if I already have a created shortcut then how do I extract
the target pathway from it, as a string??

any help greatly appreciated

Jason.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Extract Target path from a shortcut

Hi Jason,

Try something like:

'=============
Public Sub Tester()
Dim WSHShell As Object
Dim MyShortcut As Object
Dim sDesktoPath As String
Const sShortcutName As String = "YourShortcutName"

Set WSHShell = CreateObject("WScript.Shell")

sDesktopPath = WSHShell.SpecialFolders("Desktop")

Set MyShortcut = WSHShell.CreateShortcut(sDesktopPath _
& "\" & sShortcutName & ".lnk")

MsgBox MyShortcut.TargetPath

End Sub
'<<=============


---
Regards,
Norman


"WhytheQ" wrote in message
oups.com...
I know how to add a target path to a created shortcut:

Dim WSHShell As Object
Dim MyShortcut As Object

Set WSHShell = CreateObject("WScript.Shell")
Set MyShortcut = WSHShell.CreateShortcut(pathwayhere & ".lnk")

With MyShortcut
.targetpath = targetpathwayhere
.Save
End With

........but if I already have a created shortcut then how do I extract
the target pathway from it, as a string??

any help greatly appreciated

Jason.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 246
Default Extract Target path from a shortcut

Very nice Norman!
It was using the "CreateShortcut" method that fooled me: I had it in my
head that this would create a new shortcut rather than get a hook on an
existing one !!

all seems to work ok
thanks again
Jason

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to extract only file name from folder path string in Excel? JayKay Excel Worksheet Functions 1 March 20th 09 04:57 PM
Target directory & Path Param Excel Worksheet Functions 0 March 28th 06 01:52 AM
extract filename from full path Leung Excel Programming 7 August 3rd 05 10:08 PM
Extract Path From String Andibevan[_2_] Excel Programming 2 June 15th 05 07:04 PM
Extract full path given filename Kim J. Excel Programming 3 October 14th 04 04:38 AM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"