PC Review


Reply
Thread Tools Rate Thread

Add shortcut icon to a users desktop?

 
 
=?Utf-8?B?WFA=?=
Guest
Posts: n/a
 
      19th Mar 2007
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 With Quote
 
 
 
 
Ron de Bruin
Guest
Posts: n/a
 
      19th Mar 2007
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" <(E-Mail Removed)> wrote in message news:92317E25-7403-4EF3-8681-(E-Mail Removed)...
> 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 With Quote
 
=?Utf-8?B?WFA=?=
Guest
Posts: n/a
 
      19th Mar 2007
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" <(E-Mail Removed)> wrote in message news:92317E25-7403-4EF3-8681-(E-Mail Removed)...
> > 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 With Quote
 
Larry
Guest
Posts: n/a
 
      20th Nov 2009
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" <(E-Mail Removed)> wrote in message news:92317E25-7403-4EF3-8681-(E-Mail Removed)...
> > > 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 With Quote
 
Bernie Deitrick
Guest
Posts: n/a
 
      20th Nov 2009
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" <(E-Mail Removed)> wrote in message
news:C2C35ED5-A64D-4EDA-81EE-(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
>> > news:92317E25-7403-4EF3-8681-(E-Mail Removed)...
>> > > 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 With Quote
 
Larry
Guest
Posts: n/a
 
      24th Nov 2009
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" <(E-Mail Removed)> wrote in message
> news:C2C35ED5-A64D-4EDA-81EE-(E-Mail Removed)...
> > 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" <(E-Mail Removed)> wrote in message
> >> > news:92317E25-7403-4EF3-8681-(E-Mail Removed)...
> >> > > 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to make the url into an icon/shortcut on the users desktop? JB Microsoft ASP .NET 1 29th Sep 2010 12:36 PM
Re: Desktop Shortcut Icon Mike Cawood, HND BIT Windows XP General 0 14th Sep 2008 11:24 AM
Re: Desktop Shortcut Icon Mantas Mikulėnas Windows XP General 0 14th Sep 2008 10:50 AM
Re: Shortcut key for desktop shortcut icon won't stick Ramesh, MS-MVP Windows XP General 2 28th Dec 2006 05:39 AM
desktop shortcut icon Brian Microsoft Windows 2000 New Users 1 19th Nov 2003 02:15 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:40 AM.