Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Create Desktop Shortcut

Posted on 2006-11-17
4
Medium Priority
?
338 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
[X]
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
  • 2
  • 2
4 Comments
 
LVL 39

Accepted Solution

by:
stevbe earned 2000 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

636 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