Does anyone know how I can create and edit a shortcut file in VB.
I am trying to create a shortcut to a workbook and then edit the 'start in:'
field of the shortcut
Thanks
Fred
Does anyone know how I can create and edit a shortcut file in VB.
I am trying to create a shortcut to a workbook and then edit the 'start in:'
field of the shortcut
Thanks
Fred
The following example using the WScript shell object creates a shortcut to
the workbook the macro is in and sets the 'Start In' (working directory) to
C:\Scripts.
____________________________________________
strWkbkTgt = ThisWorkbook.Path & "\" & ThisWorkbook.Name
Set objWSH = CreateObject("WScript.Shell")
strDesktop = objWSH.SpecialFolders("Desktop")
Set objLink = objWSH.CreateShortcut(strDesktop & "\" & ThisWorkbook.Name &
".lnk")
objLink.TargetPath = strWkbkTgt
objLink.WorkingDirectory = "C:\Scripts"
objLink.Save
______________________________________________
Steve
"Fred" <leavemealone@home> wrote in message
news:[email protected]...
> Does anyone know how I can create and edit a shortcut file in VB.
> I am trying to create a shortcut to a workbook and then edit the 'start
> in:' field of the shortcut
>
> Thanks
> Fred
>
>
Thanks Steve, that works perfectly.
Fred
"Steve Yandl" <[email protected]> wrote in message
news:[email protected]...
> The following example using the WScript shell object creates a shortcut to
> the workbook the macro is in and sets the 'Start In' (working directory)
> to C:\Scripts.
>
> ____________________________________________
>
> strWkbkTgt = ThisWorkbook.Path & "\" & ThisWorkbook.Name
>
> Set objWSH = CreateObject("WScript.Shell")
> strDesktop = objWSH.SpecialFolders("Desktop")
>
> Set objLink = objWSH.CreateShortcut(strDesktop & "\" & ThisWorkbook.Name &
> ".lnk")
> objLink.TargetPath = strWkbkTgt
> objLink.WorkingDirectory = "C:\Scripts"
> objLink.Save
>
> ______________________________________________
>
> Steve
>
>
>
> "Fred" <leavemealone@home> wrote in message
> news:[email protected]...
>> Does anyone know how I can create and edit a shortcut file in VB.
>> I am trying to create a shortcut to a workbook and then edit the 'start
>> in:' field of the shortcut
>>
>> Thanks
>> Fred
>>
>>
>
>
You're welcome. The object also lets you set WindowStyle, HotKey, and
IconLocation (icon choice) for the shortcut but I've never found any of them
important enough to include in routines I write.
Steve
"Fred" <leavemealone@home> wrote in message
news:e%[email protected]...
> Thanks Steve, that works perfectly.
>
> Fred
>
> "Steve Yandl" <[email protected]> wrote in message
> news:[email protected]...
>> The following example using the WScript shell object creates a shortcut
>> to the workbook the macro is in and sets the 'Start In' (working
>> directory) to C:\Scripts.
>>
>> ____________________________________________
>>
>> strWkbkTgt = ThisWorkbook.Path & "\" & ThisWorkbook.Name
>>
>> Set objWSH = CreateObject("WScript.Shell")
>> strDesktop = objWSH.SpecialFolders("Desktop")
>>
>> Set objLink = objWSH.CreateShortcut(strDesktop & "\" & ThisWorkbook.Name
>> & ".lnk")
>> objLink.TargetPath = strWkbkTgt
>> objLink.WorkingDirectory = "C:\Scripts"
>> objLink.Save
>>
>> ______________________________________________
>>
>> Steve
>>
>>
>>
>> "Fred" <leavemealone@home> wrote in message
>> news:[email protected]...
>>> Does anyone know how I can create and edit a shortcut file in VB.
>>> I am trying to create a shortcut to a workbook and then edit the 'start
>>> in:' field of the shortcut
>>>
>>> Thanks
>>> Fred
>>>
>>>
>>
>>
>
>
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks