Solved

Create Desktop Shortcut

Posted on 2006-11-17
4
329 Views
Last Modified: 2008-01-16
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
0
Comment
Question by:Rob4077
  • 2
  • 2
4 Comments
 
LVL 39

Accepted Solution

by:
stevbe earned 500 total points
ID: 17964758

Public Function MakeShortcut()

  Dim scr As Object
  Dim scrLink As Object
  Dim strPath As String
  Set scr = CreateObject("WScript.Shell")

  strPath = scr.SpecialFolders("Desktop") & "\test.lnk"
 
  Set scrLink = scr.CreateShortcut(strPath)
 
  scrLink.TargetPath = "C:\MyApp.mdb"
  scrLink.IconLocation = "C:\MyApp.bmp"
  scrLink.Save

  Set scrLink = Nothing
  Set scr = Nothing

End Function

here is a great link:
http://www.windowsdevcenter.com/pub/a/windows/2004/04/13/VB_Shortcuts.html
0
 

Author Comment

by:Rob4077
ID: 17964972
That works BRILLIANTLY!!! Thanks.
0
 
LVL 39

Expert Comment

by:stevbe
ID: 17966275
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
0
 

Author Comment

by:Rob4077
ID: 17974310
Sorry for the delay - forgot.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now