Create Desktop Shortcut
Posted on 2006-11-17
I would like to create a VBA module that will create a desktop shortcut that will launch my application: "C:\MyApp.mdb" , name the shortcut "My Application" and use the file "C:\MyApp.bmp" as the icon for the desktop shortcut. I have found the following module on another question on EE but cannot get it to work. Can anyone help me achieve what I need?
Private Sub Form_Load()
'... do whatever you're doing already here
Dim icon As String
'Change "house.ico" to whatever your icon is... if you wanted you could
'name the icon the same as the .mdb file and then just autoload it like this:
'icon = Application.CurrentProject.FullName & ".ico" 'looks for c:\path\to\my.mdb.ico
icon = Application.CurrentProject.Path & "\house.ico"
Dim dbs As Database
Set dbs = CurrentDb()
On Error Resume Next
If dbs.Properties("AppIcon") Is Nothing Then
' Create property if necessary.
Dim prp As Property
Set prp = dbs.CreateProperty("AppIcon", dbText, icon)
Set prp = Nothing
' Property already exists, just save new value.
dbs.Properties("AppIcon").Value = icon