PC Review


Reply
Thread Tools Rate Thread

copy shortcut to desktop

 
 
Michelle
Guest
Posts: n/a
 
      13th Nov 2008
Hi!

I'm new to excel but kinda familiar with VBA for Access. I would like to
copy stored shortcuts(.lnk) to the users desktop. I have the following code.
I was trying the FileCopy but I'm pretty sure I should be using CopyFile.
What do I need to make the FileSystemObject work?

Private Sub cmdCreateDesktopShortcut_Click()

'Dim FSO As FileSystemObject
Dim strUserDesktop
Dim strDrive As String
Dim strTempPath As String
Dim strSrcePath As String

'Set FSO = New FileSystemObject

'Set up Source string

strSrcePath = "bwes.net\Barberton file
shares\DocControlPLM\BatchLoadFiles\ScriptsAndZips\Shortcuts\Consolidated -
Approve.lnk"

'Set up Destination string

strDrive = "D:"
strTempPath = "\Documents and Settings\" & Environ("USERNAME") & "\Desktop\"

strUserDesktop = Dir(strDrive & strTempPath)

Kill strUserDesktop

FileCopy strSrcePath, strUserDesktop

End Sub


 
Reply With Quote
 
 
 
 
Joel
Guest
Posts: n/a
 
      14th Nov 2008
filecopy should work. You have the following error

from
strDrive = "D:"
strTempPath = "\Documents and Settings\" & Environ("USERNAME") & "\Desktop\"

strUserDesktop = Dir(strDrive & strTempPath)

Kill strUserDesktop

FileCopy strSrcePath, strUserDesktop
to
strDrive = "D:"
strTempPath = "\Documents and Settings\" & Environ("USERNAME") & "\Desktop\"

Kill strTempPath & "*.*"

FileCopy strSrcePath, strTempPath & "Approve.lnk"



DIR will remove the PATH name from the filename giving you just the file name

I would change the envirnomenttal settings you are using since not
everybody will be on drive D:.

first I would look at the envirnomental setting at your company by doing the
following:
1) From start button: select RUN. In the run box type cmd.exe the OK
2) From command prompt type SET. This will give you the list of
envirnomental settings.

from
strDrive = "D:"
strTempPath = "\Documents and Settings\" & Environ("USERNAME") & "\Desktop\"

to

strTempPath = environ("USERPROFILE") & "\Desktop\"




"Michelle" wrote:

> Hi!
>
> I'm new to excel but kinda familiar with VBA for Access. I would like to
> copy stored shortcuts(.lnk) to the users desktop. I have the following code.
> I was trying the FileCopy but I'm pretty sure I should be using CopyFile.
> What do I need to make the FileSystemObject work?
>
> Private Sub cmdCreateDesktopShortcut_Click()
>
> 'Dim FSO As FileSystemObject
> Dim strUserDesktop
> Dim strDrive As String
> Dim strTempPath As String
> Dim strSrcePath As String
>
> 'Set FSO = New FileSystemObject
>
> 'Set up Source string
>
> strSrcePath = "bwes.net\Barberton file
> shares\DocControlPLM\BatchLoadFiles\ScriptsAndZips\Shortcuts\Consolidated -
> Approve.lnk"
>
> 'Set up Destination string
>
> strDrive = "D:"
> strTempPath = "\Documents and Settings\" & Environ("USERNAME") & "\Desktop\"
>
> strUserDesktop = Dir(strDrive & strTempPath)
>
> Kill strUserDesktop
>
> FileCopy strSrcePath, strUserDesktop
>
> End Sub
>
>

 
Reply With Quote
 
Michelle
Guest
Posts: n/a
 
      14th Nov 2008
Joel

Thanks. I made the changes that you suggested but I get a run-time error
"76" Path not found.

Is there a problem with the way it sees the shortcut "Consolidated -
Approve.lnk"? The way its stored on the network is - (star icon)Consolidated
- Approve No .lnk suffix.
I took the Kill statement out. Don't want to delete strTempPath before I
have a chance to use it. If I put my cursor over the variables they show the
paths exactly the way they should.

"Joel" wrote:

> filecopy should work. You have the following error
>
> from
> strDrive = "D:"
> strTempPath = "\Documents and Settings\" & Environ("USERNAME") & "\Desktop\"
>
> strUserDesktop = Dir(strDrive & strTempPath)
>
> Kill strUserDesktop
>
> FileCopy strSrcePath, strUserDesktop
> to
> strDrive = "D:"
> strTempPath = "\Documents and Settings\" & Environ("USERNAME") & "\Desktop\"
>
> Kill strTempPath & "*.*"
>
> FileCopy strSrcePath, strTempPath & "Approve.lnk"
>
>
>
> DIR will remove the PATH name from the filename giving you just the file name
>
> I would change the envirnomenttal settings you are using since not
> everybody will be on drive D:.
>
> first I would look at the envirnomental setting at your company by doing the
> following:
> 1) From start button: select RUN. In the run box type cmd.exe the OK
> 2) From command prompt type SET. This will give you the list of
> envirnomental settings.
>
> from
> strDrive = "D:"
> strTempPath = "\Documents and Settings\" & Environ("USERNAME") & "\Desktop\"
>
> to
>
> strTempPath = environ("USERPROFILE") & "\Desktop\"
>
>
>
>
> "Michelle" wrote:
>
> > Hi!
> >
> > I'm new to excel but kinda familiar with VBA for Access. I would like to
> > copy stored shortcuts(.lnk) to the users desktop. I have the following code.
> > I was trying the FileCopy but I'm pretty sure I should be using CopyFile.
> > What do I need to make the FileSystemObject work?
> >
> > Private Sub cmdCreateDesktopShortcut_Click()
> >
> > 'Dim FSO As FileSystemObject
> > Dim strUserDesktop
> > Dim strDrive As String
> > Dim strTempPath As String
> > Dim strSrcePath As String
> >
> > 'Set FSO = New FileSystemObject
> >
> > 'Set up Source string
> >
> > strSrcePath = "bwes.net\Barberton file
> > shares\DocControlPLM\BatchLoadFiles\ScriptsAndZips\Shortcuts\Consolidated -
> > Approve.lnk"
> >
> > 'Set up Destination string
> >
> > strDrive = "D:"
> > strTempPath = "\Documents and Settings\" & Environ("USERNAME") & "\Desktop\"
> >
> > strUserDesktop = Dir(strDrive & strTempPath)
> >
> > Kill strUserDesktop
> >
> > FileCopy strSrcePath, strUserDesktop
> >
> > End Sub
> >
> >

 
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
Copy shortcut to desktop =?Utf-8?B?U2hhbGxub3Q=?= Windows XP General 2 17th Oct 2005 06:54 PM
Copy a shortcut to desktop at startup =?Utf-8?B?RmFicnVzc2lv?= Microsoft Windows 2000 4 24th Mar 2005 02:49 PM
How do I make a copy command shortcut on my desktop PeterM Windows XP General 5 27th Feb 2004 03:49 PM
Copy shortcut to user desktop James Microsoft Windows 2000 Active Directory 1 9th Aug 2003 02:51 PM
Copy shortcut to user desktop James Microsoft Windows 2000 New Users 2 9th Aug 2003 07:51 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:53 PM.