Solved

Create Desktop Shortcut

Posted on 2006-11-17
4
332 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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

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…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

730 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