Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 73
Default Editing Shortcut files

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 284
Default Editing Shortcut files

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
...
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




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 73
Default Editing Shortcut files

Thanks Steve, that works perfectly.

Fred

"Steve Yandl" wrote in message
. ..
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
...
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






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 284
Default Editing Shortcut files

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
...
Thanks Steve, that works perfectly.

Fred

"Steve Yandl" wrote in message
. ..
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
...
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








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
vista & XP editing web files Gnarly Excel Discussion (Misc queries) 2 March 11th 07 12:58 PM
EXCEL files locked for editing ATK31 Excel Discussion (Misc queries) 2 August 31st 06 11:18 PM
Can I use Excel, opening and editing files, online? AlisonHunter Excel Discussion (Misc queries) 0 June 1st 06 11:41 AM
KB shortcut to switch between files Jason O New Users to Excel 2 April 12th 06 09:17 PM
Importing/Exporting text files and string editing Slick Willie Excel Programming 1 September 23rd 04 12:24 AM


All times are GMT +1. The time now is 04:30 AM.

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"