Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Create Desktop Shortcut

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

789 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