Access 2007 programmatically create a desktop database shortcut with made icon

Posted on 2009-04-25
Last Modified: 2013-11-27
Im using Access 2007.
 I changed my Dbs default icon in the Application Options. It work fine in the forms view and when the Db is open the icon show as intended in the bottom Window tool bar. My question is; how can I change the icon of the database when making a short cut to the desktop? Im getting ready to distribute a Db that I what it to be distinctive to the user endless list Access Dbs shortcuts. Can this be done programmatically?  
Question by:Exl04
    LVL 3

    Accepted Solution

    use WScript object to create shortcut
    Sub t()
        Dim WshShell As Object
        Dim oShellLink As Object
        Set WshShell = CreateObject("WScript.Shell")
        strDesktop = WshShell.SpecialFolders("Desktop")
        Set oShellLink = WshShell.CreateShortcut(strDesktop & "\Shortcut Script.lnk")
        oShellLink.TargetPath = "c:\application\database.mdb"
        oShellLink.WorkingDirectory = "c:\application\"
        oShellLink.WindowStyle = 1
        oShellLink.Hotkey = "CTRL+SHIFT+F" 'if you need
        oShellLink.IconLocation = "notepad.exe, 0" ' icon or file with icons and number
        oShellLink.Description = "Shortcut Script"
        Set oShellLink = Nothing
        Set WshShell = Nothing
    End Sub

    Open in new window

    LVL 1

    Author Comment

    Thanks for you idea. How can I apply this script? If I put a command button in the main database switchboard some this like "Create a Shortcut to this Db in Your Desktop" can it run from there? And if the shortcut already exists will it create another one?
    On this line;
    oShellLink.IconLocation = "notepad.exe, 0" ' icon or file with icons and number
    if I created my own icon, can I just put the path of where it is? And what does number means?
    LVL 46

    Expert Comment

    Hi Exl04,

    Have a look at the following:

    Good Luck!

    LVL 1

    Author Comment

    tbsqadi, thanks for the information. I still can see how to make it work.  How can I make it happen from the database? Does anybody have an example code or another link of how is done?
    LVL 1

    Author Closing Comment

    Thank for you input

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    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…
    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…
    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…
    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…

    779 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

    14 Experts available now in Live!

    Get 1:1 Help Now