Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Jim Jim is offline
external usenet poster
 
Posts: 615
Default Make a shortcut to a file - code

I want to make a shortcut to a file and place it in another folder. The name
of the file will be something like "shortcut to myfile.xls"
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Make a shortcut to a file - code

Hi Jim

This example will place a shortcut to the activeworkbook on the desktop
Change DesktopPath to your folder


Sub Desktopshortcut()
Dim WSHShell As Object
Dim MyShortcut As Object
Dim DesktopPath As String
Set WSHShell = CreateObject("WScript.Shell")
DesktopPath = WSHShell.SpecialFolders("Desktop")
Set MyShortcut = WSHShell.CreateShortcut(DesktopPath & "\" & _
ActiveWorkbook.Name & ".lnk")
With MyShortcut
.TargetPath = ActiveWorkbook.FullName
.Save
End With
Set WSHShell = Nothing
MsgBox "A shortcut has been placed on your desktop."
End Sub




--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Jim" wrote in message ...
I want to make a shortcut to a file and place it in another folder. The name
of the file will be something like "shortcut to myfile.xls"

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Make a shortcut to a file - code

If you don't get a better answer, look at this:

http://support.microsoft.com/kb/242297/en-us
HOWTO: Use Windows Script Host to Create Shortcut with Parameters

--
Regards,
Tom Ogilvy


"Jim" wrote:

I want to make a shortcut to a file and place it in another folder. The name
of the file will be something like "shortcut to myfile.xls"

  #4   Report Post  
Posted to microsoft.public.excel.programming
Jim Jim is offline
external usenet poster
 
Posts: 615
Default Make a shortcut to a file - code

Thanks, got this to work. Didnt origionally plan on making the active
workbook the file for the source but it actually turned out to work better.
thanks again everyone.


"Ron de Bruin" wrote:

Hi Jim

This example will place a shortcut to the activeworkbook on the desktop
Change DesktopPath to your folder


Sub Desktopshortcut()
Dim WSHShell As Object
Dim MyShortcut As Object
Dim DesktopPath As String
Set WSHShell = CreateObject("WScript.Shell")
DesktopPath = WSHShell.SpecialFolders("Desktop")
Set MyShortcut = WSHShell.CreateShortcut(DesktopPath & "\" & _
ActiveWorkbook.Name & ".lnk")
With MyShortcut
.TargetPath = ActiveWorkbook.FullName
.Save
End With
Set WSHShell = Nothing
MsgBox "A shortcut has been placed on your desktop."
End Sub




--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Jim" wrote in message ...
I want to make a shortcut to a file and place it in another folder. The name
of the file will be something like "shortcut to myfile.xls"


  #5   Report Post  
Posted to microsoft.public.excel.programming
Jim Jim is offline
external usenet poster
 
Posts: 615
Default Make a shortcut to a file - code

ok, part 2: what if I want the code to create a shortcut to a folder? I cant
use the active workbook name, SO, would i just set the target path =
c:\thepathIWant??? And would the extention still be .ink for MyShortcut?

================================================== ===

"Tom Ogilvy" wrote:

If you don't get a better answer, look at this:

http://support.microsoft.com/kb/242297/en-us
HOWTO: Use Windows Script Host to Create Shortcut with Parameters

--
Regards,
Tom Ogilvy


"Jim" wrote:

I want to make a shortcut to a file and place it in another folder. The name
of the file will be something like "shortcut to myfile.xls"

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
Make shortcut to Excelfile on desktop excelent Excel Programming 4 September 16th 07 06:54 PM
I need a shortcut to make a excel file open to a specific sheet EAHRENS Excel Discussion (Misc queries) 9 December 6th 05 06:51 PM
How to make repeat long numbers shortcut ? toyota58 Excel Worksheet Functions 1 August 20th 05 06:20 PM
How do I make toggling shortcut keys for superscript and subscript? Mann Lee Excel Programming 2 December 11th 04 03:36 PM
How to make a list of all shortcut keys Helge V. Larsen[_3_] Excel Programming 8 October 7th 04 04:25 AM


All times are GMT +1. The time now is 09:52 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"