1. Is it possible to create a button in a database that will create a shortcut on the desktop?
2. If so, is it possible to have the icon of that shortcut default to a particular icon?
3. If so, is it possible to have the name of that shortcut on the desktop default to particular text?
Thank you in anticipation.
Is a button for a desktop shortcut possible?
-
- 4StarLounger
- Posts: 582
- Joined: 06 May 2012, 20:05
-
- Administrator
- Posts: 78545
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Is a button for a desktop shortcut possible?
Like this:
This will create a desktop shortcut to the database from which the code is run. Change the path and name of the icon file to be used.
Code: Select all
Private Sub cmdCreateShortcut_Click()
Dim objWSH As Object
Dim objShortcut As Object
Dim strDeskTop As String
Set objWSH = CreateObject("WScript.Shell")
strDeskTop = objWSH.SpecialFolders("Desktop")
Set objShortcut = objWSH.CreateShortCut(strDeskTop & "\" & "MyShortcut" & ".lnk")
With objShortcut
.TargetPath = CurrentDb.Name
.IconLocation = "C:\Program Files\Internet Explorer\Images\Bing.ico"
.Save
End With
Set objWSH = Nothing
End Sub
Best wishes,
Hans
Hans
-
- 4StarLounger
- Posts: 582
- Joined: 06 May 2012, 20:05
Re: Is a button for a desktop shortcut possible?
Yeee haaa! Lovely, Hans! Just what I wanted. Initially I didn't change "MyShortcut" to what I wanted, but have now and it is perrrrrrrrrfect!
Thank you!
Thank you!