Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
XP XP is offline
external usenet poster
 
Posts: 389
Default Add shortcut icon to a users desktop?

Using Office 2003 and Windows XP.

Is it possible to copy a file to a user's desktop folder and then add a
shortcut icon to the file to that user's desktop?

If so, could someone please post example VBA code to do this? It would solve
my deployment issues for a program...
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Add shortcut icon to a users desktop?

Hi XP

You can find code here to find the path of the desktop
http://www.rondebruin.nl/folder.htm#SpecialFolders


To create a shortcut to the activeworkbook try

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


"XP" wrote in message ...
Using Office 2003 and Windows XP.

Is it possible to copy a file to a user's desktop folder and then add a
shortcut icon to the file to that user's desktop?

If so, could someone please post example VBA code to do this? It would solve
my deployment issues for a program...

  #3   Report Post  
Posted to microsoft.public.excel.programming
XP XP is offline
external usenet poster
 
Posts: 389
Default Add shortcut icon to a users desktop?

VERY, VERY NICE !

Thanks a lot Ron! - just what I needed.

"Ron de Bruin" wrote:

Hi XP

You can find code here to find the path of the desktop
http://www.rondebruin.nl/folder.htm#SpecialFolders


To create a shortcut to the activeworkbook try

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


"XP" wrote in message ...
Using Office 2003 and Windows XP.

Is it possible to copy a file to a user's desktop folder and then add a
shortcut icon to the file to that user's desktop?

If so, could someone please post example VBA code to do this? It would solve
my deployment issues for a program...


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Add shortcut icon to a users desktop?

How do you remove that shortcut using VBA code? Thank you
--
Larry


"XP" wrote:

VERY, VERY NICE !

Thanks a lot Ron! - just what I needed.

"Ron de Bruin" wrote:

Hi XP

You can find code here to find the path of the desktop
http://www.rondebruin.nl/folder.htm#SpecialFolders


To create a shortcut to the activeworkbook try

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


"XP" wrote in message ...
Using Office 2003 and Windows XP.

Is it possible to copy a file to a user's desktop folder and then add a
shortcut icon to the file to that user's desktop?

If so, could someone please post example VBA code to do this? It would solve
my deployment issues for a program...


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Add shortcut icon to a users desktop?

Larry,

See macros below.

HTH,
Bernie
MS Excel MVP

Sub CreateDesktopShortcut()
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

Sub DeleteDesktopShortcut()
Dim WSHShell As Object
Dim MyShortcut As Object
Dim DesktopPath As String
Set WSHShell = CreateObject("WScript.Shell")
DesktopPath = WSHShell.SpecialFolders("Desktop")
On Error GoTo NotFound
Kill (DesktopPath & "\" & ActiveWorkbook.Name & ".lnk")
MsgBox "A shortcut has been removed from your desktop."
Set WSHShell = Nothing
Exit Sub
NotFound:
MsgBox "A shortcut to the active workbook was not found on your desktop."
Set WSHShell = Nothing
End Sub



"Larry" wrote in message
...
How do you remove that shortcut using VBA code? Thank you
--
Larry


"XP" wrote:

VERY, VERY NICE !

Thanks a lot Ron! - just what I needed.

"Ron de Bruin" wrote:

Hi XP

You can find code here to find the path of the desktop
http://www.rondebruin.nl/folder.htm#SpecialFolders


To create a shortcut to the activeworkbook try

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


"XP" wrote in message
...
Using Office 2003 and Windows XP.

Is it possible to copy a file to a user's desktop folder and then add a
shortcut icon to the file to that user's desktop?

If so, could someone please post example VBA code to do this? It would solve
my deployment issues for a program...





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Add shortcut icon to a users desktop?

Thank you.
--
Larry


"Bernie Deitrick" wrote:

Larry,

See macros below.

HTH,
Bernie
MS Excel MVP

Sub CreateDesktopShortcut()
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

Sub DeleteDesktopShortcut()
Dim WSHShell As Object
Dim MyShortcut As Object
Dim DesktopPath As String
Set WSHShell = CreateObject("WScript.Shell")
DesktopPath = WSHShell.SpecialFolders("Desktop")
On Error GoTo NotFound
Kill (DesktopPath & "\" & ActiveWorkbook.Name & ".lnk")
MsgBox "A shortcut has been removed from your desktop."
Set WSHShell = Nothing
Exit Sub
NotFound:
MsgBox "A shortcut to the active workbook was not found on your desktop."
Set WSHShell = Nothing
End Sub



"Larry" wrote in message
...
How do you remove that shortcut using VBA code? Thank you
--
Larry


"XP" wrote:

VERY, VERY NICE !

Thanks a lot Ron! - just what I needed.

"Ron de Bruin" wrote:

Hi XP

You can find code here to find the path of the desktop
http://www.rondebruin.nl/folder.htm#SpecialFolders


To create a shortcut to the activeworkbook try

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


"XP" wrote in message
...
Using Office 2003 and Windows XP.

Is it possible to copy a file to a user's desktop folder and then add a
shortcut icon to the file to that user's desktop?

If so, could someone please post example VBA code to do this? It would solve
my deployment issues for a program...



.

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
Desktop File Icon Josh O. Setting up and Configuration of Excel 3 August 23rd 07 09:30 PM
Desktop icon name Les Stout[_2_] Excel Programming 4 March 6th 07 02:29 PM
Change desktop icon Tempy Excel Programming 3 September 21st 05 05:01 PM
how can i put the excel icon on my desktop? petre Excel Discussion (Misc queries) 4 February 20th 05 05:29 PM
Running a macro from a desktop icon shortcut Sofia Excel Programming 2 July 15th 03 08:01 PM


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