Link to home
Start Free TrialLog in
Avatar of Rob4077
Rob4077Flag for Australia

asked on

Create Desktop Shortcut

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)
        dbs.Properties.Append prp
        Set prp = Nothing
    Else
        ' Property already exists, just save new value.
        dbs.Properties("AppIcon").Value = icon
    End If
   
    Application.RefreshTitleBar
    Application.RefreshDatabaseWindow
ASKER CERTIFIED SOLUTION
Avatar of stevbe
stevbe

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Rob4077

ASKER

That works BRILLIANTLY!!! Thanks.
Avatar of stevbe
stevbe

Glad to hear it worked for you. If you are all set, please accept my post so we can close this one down and move on :-)

Steve
Avatar of Rob4077

ASKER

Sorry for the delay - forgot.