PC Review


Reply
Thread Tools Rate Thread

Desktop icon name

 
 
Les Stout
Guest
Posts: n/a
 
      6th Mar 2007
Hi all, i have the code below to install an icon on my desktop of the
active workbook, i however want the name to be different. Could somebody
please help me to change the code. (I have been trying all day and can't
get it to work !!) I want it to be Creditors
Reconciliation

'------------------- Create a short cut on the desktop
----------------------------------------
Sub CreateShortCut()
'
Dim oWSH As Object
Dim oShortcut As Object
Dim sPathDeskTop As String
Dim testStr As String

Set oWSH = CreateObject("WScript.Shell")
sPathDeskTop = oWSH.SpecialFolders("Desktop")
testStr = ""
On Error Resume Next
testStr = Dir(sPathDeskTop & "\" & ActiveWorkbook.Name & ".lnk")
On Error GoTo 0
If testStr = "" Then
'------------------ If shortcut not found create
----------------------------------------------
Set oShortcut = oWSH.CreateShortCut(sPathDeskTop & "\" & _
ActiveWorkbook.Name & ".lnk")
With oShortcut
.Description = "Creditors" & vbCrLf & _
"Reconciliation"
.TargetPath = ActiveWorkbook.FullName
.IconLocation = "\\nv09002\tpdrive\TM-Recon\macro\scale.ico"
.Save
End With
Set oWSH = Nothing
'-Msg to tell user about the folders & shortcut
-------------------------------
Application.StatusBar = False
MsgBox "The desktop shortcut has been installed"
Else
MsgBox "The desktop shortcut is already installed"
End If

End Sub


Les Stout

*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      6th Mar 2007
One way:

Option Explicit
Sub CreateShortCut()
'
Dim oWSH As Object
Dim oShortcut As Object
Dim sPathDeskTop As String
Dim testStr As String
Dim myNewName As String

Set oWSH = CreateObject("WScript.Shell")
sPathDeskTop = oWSH.SpecialFolders("Desktop")

myNewName = "Something else goes here" '<-- change this line

testStr = ""
On Error Resume Next
testStr = Dir(sPathDeskTop & "\" & myNewName & ".lnk")
On Error GoTo 0
If testStr = "" Then
'------------------ If shortcut not found create
Set oShortcut = oWSH.CreateShortCut(sPathDeskTop & "\" & _
myNewName & ".lnk")
With oShortcut
.Description = "Creditors" & vbCrLf & _
"Reconciliation"
.TargetPath = ActiveWorkbook.FullName
.IconLocation = "\\nv09002\tpdrive\TM-Recon\macro\scale.ico"
.Save
End With
Set oWSH = Nothing
'-Msg to tell user about the folders & shortcut
Application.StatusBar = False
MsgBox "The desktop shortcut has been installed"
Else
MsgBox "The desktop shortcut is already installed"
End If

End Sub

Les Stout wrote:
>
> Hi all, i have the code below to install an icon on my desktop of the
> active workbook, i however want the name to be different. Could somebody
> please help me to change the code. (I have been trying all day and can't
> get it to work !!) I want it to be Creditors
> Reconciliation
>
> '------------------- Create a short cut on the desktop
> ----------------------------------------
> Sub CreateShortCut()
> '
> Dim oWSH As Object
> Dim oShortcut As Object
> Dim sPathDeskTop As String
> Dim testStr As String
>
> Set oWSH = CreateObject("WScript.Shell")
> sPathDeskTop = oWSH.SpecialFolders("Desktop")
> testStr = ""
> On Error Resume Next
> testStr = Dir(sPathDeskTop & "\" & ActiveWorkbook.Name & ".lnk")
> On Error GoTo 0
> If testStr = "" Then
> '------------------ If shortcut not found create
> ----------------------------------------------
> Set oShortcut = oWSH.CreateShortCut(sPathDeskTop & "\" & _
> ActiveWorkbook.Name & ".lnk")
> With oShortcut
> .Description = "Creditors" & vbCrLf & _
> "Reconciliation"
> .TargetPath = ActiveWorkbook.FullName
> .IconLocation = "\\nv09002\tpdrive\TM-Recon\macro\scale.ico"
> .Save
> End With
> Set oWSH = Nothing
> '-Msg to tell user about the folders & shortcut
> -------------------------------
> Application.StatusBar = False
> MsgBox "The desktop shortcut has been installed"
> Else
> MsgBox "The desktop shortcut is already installed"
> End If
>
> End Sub
>
> Les Stout
>
> *** Sent via Developersdex http://www.developersdex.com ***


--

Dave Peterson
 
Reply With Quote
 
=?Utf-8?B?R2FyeScncyBTdHVkZW50?=
Guest
Posts: n/a
 
      6th Mar 2007
Near the start of your code include:

newname = Application.InputBox("Enter desired shortcut name:", Type:=2)

And then in place of:

ActiveWorkbook.Name & ".lnk"

use

newname & ".lnk")

throughout
--
Gary''s Student
gsnu200709


"Les Stout" wrote:

> Hi all, i have the code below to install an icon on my desktop of the
> active workbook, i however want the name to be different. Could somebody
> please help me to change the code. (I have been trying all day and can't
> get it to work !!) I want it to be Creditors
> Reconciliation
>
> '------------------- Create a short cut on the desktop
> ----------------------------------------
> Sub CreateShortCut()
> '
> Dim oWSH As Object
> Dim oShortcut As Object
> Dim sPathDeskTop As String
> Dim testStr As String
>
> Set oWSH = CreateObject("WScript.Shell")
> sPathDeskTop = oWSH.SpecialFolders("Desktop")
> testStr = ""
> On Error Resume Next
> testStr = Dir(sPathDeskTop & "\" & ActiveWorkbook.Name & ".lnk")
> On Error GoTo 0
> If testStr = "" Then
> '------------------ If shortcut not found create
> ----------------------------------------------
> Set oShortcut = oWSH.CreateShortCut(sPathDeskTop & "\" & _
> ActiveWorkbook.Name & ".lnk")
> With oShortcut
> .Description = "Creditors" & vbCrLf & _
> "Reconciliation"
> .TargetPath = ActiveWorkbook.FullName
> .IconLocation = "\\nv09002\tpdrive\TM-Recon\macro\scale.ico"
> .Save
> End With
> Set oWSH = Nothing
> '-Msg to tell user about the folders & shortcut
> -------------------------------
> Application.StatusBar = False
> MsgBox "The desktop shortcut has been installed"
> Else
> MsgBox "The desktop shortcut is already installed"
> End If
>
> End Sub
>
>
> Les Stout
>
> *** Sent via Developersdex http://www.developersdex.com ***
>

 
Reply With Quote
 
Les Stout
Guest
Posts: n/a
 
      6th Mar 2007
Thanks Dave, will give it a try...

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
Les Stout
Guest
Posts: n/a
 
      6th Mar 2007
Thanks Gary's Student

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***
 
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
Re: IE7 icon not available as a desktop icon?/Right click taskbar>toolbars>address Chad Harris Windows Vista Installation 0 20th Dec 2006 01:47 AM
when i click any icon in the desktop, it try to delete the icon =?Utf-8?B?Um9uIEphY29i?= Windows XP General 1 9th Dec 2006 10:34 AM
Re: Network Drive Icon Covering Desktop Icon. Dave Patrick Microsoft Windows 2000 1 9th Aug 2004 09:47 PM
Recycle Bin Desktop Icon isdisplayed as a normal windows folder icon Olivier Windows XP Customization 3 30th Aug 2003 05:34 AM
Re: Duplicate Icon in Control Panel - Missing Icon from Desktop Kelly Windows XP General 1 27th Jul 2003 08:53 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:29 AM.