Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default windows file shortcut using vb

i would like vb to create a shortcut to a file i have and put that shortcut
into a parent folder. I think that the ShellLink function will work but i
don't know how to do it. Any suggestions? im stumped.
Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default windows file shortcut using vb

Here is some code

Sub CreateShortCut()
Dim oWSH As Object
Dim oShortcut As Object
Dim sPath As String

Set oWSH = CreateObject("WScript.Shell")
sPath = "C:\myFolder"

Set oShortcut = oWSH.CreateShortCut(sPath & "\" & _
ActiveWorkbook.Name & ".lnk")
With oShortcut
.TargetPath = ActiveWorkbook.FullName
.Save
End With

Set oWSH = Nothing

End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Mike C" wrote in message
...
i would like vb to create a shortcut to a file i have and put that

shortcut
into a parent folder. I think that the ShellLink function will work but i
don't know how to do it. Any suggestions? im stumped.
Thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default windows file shortcut using vb

Thanks that helped me a whole lot!

"Bob Phillips" wrote:

Here is some code

Sub CreateShortCut()
Dim oWSH As Object
Dim oShortcut As Object
Dim sPath As String

Set oWSH = CreateObject("WScript.Shell")
sPath = "C:\myFolder"

Set oShortcut = oWSH.CreateShortCut(sPath & "\" & _
ActiveWorkbook.Name & ".lnk")
With oShortcut
.TargetPath = ActiveWorkbook.FullName
.Save
End With

Set oWSH = Nothing

End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Mike C" wrote in message
...
i would like vb to create a shortcut to a file i have and put that

shortcut
into a parent folder. I think that the ShellLink function will work but i
don't know how to do it. Any suggestions? im stumped.
Thanks




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
Using a Windows Shortcut to Open to Specific Sheet in Workbook Staying Productive Excel Discussion (Misc queries) 4 December 22nd 09 04:37 PM
keyboard shortcut for moving between windows c_new Excel Discussion (Misc queries) 7 October 11th 05 04:31 PM
Excel shortcut/Multiple windows weirdness [email protected] Excel Discussion (Misc queries) 7 September 24th 05 07:08 PM
Desktop shortcut to a named Excel file - every time I open it adds a "1" to the file name - how to disable? [email protected] Setting up and Configuration of Excel 2 November 27th 04 09:02 PM
Keyboard shortcut for Maximizing Windows SuperJas Excel Programming 2 March 2nd 04 05:41 AM


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