Create Shortcut on Desktop
Create Shortcut on Desktop
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 9 of 9

Thread: Create Shortcut on Desktop

  1. #1
    Board Regular
    Join Date
    Feb 2002
    Location
    John G
    Posts
    62
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    What vba code can I use to create a shortcut and windows taskbar item with a unique icon associated with it that will launch an excel file?

  2. #2
    Board Regular
    Join Date
    Feb 2002
    Posts
    3,169
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hi --

    No need for VBA jusr right click on the desktop and click shortcut.... follow the wizards / commands or click the doc to create shortcut and your see arrow o the doc put that on desktop and click to open that doc froms its dir via shortcut on desktop

    HTH

    Free Excel based Web Toolbar available here.

    Jack in the UK
    J & R Excel Solutions
    "making Excel work for you"

  3. #3
    Board Regular
    Join Date
    Feb 2002
    Posts
    65
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    From either Windows Explorer or MyComputer, browse to the file of your choice, Right click and drag to desktop. This will give you three choices.
    Move file here
    Copy File here
    Create Shortcut here
    You can decide which one to use

  4. #4
    Board Regular
    Join Date
    Feb 2002
    Location
    John G
    Posts
    62
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I understand the mechanics of creating a shortcut on the destktop by hand or manually. But I'm trying to build a kind of installation program in excel VBA that will install the shortcut and quick launch. Anybody with ideas on code that creates a shortcut and taskbar launch button?

    John

  5. #5
    MrExcel MVP Ivan F Moala's Avatar
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    4,209
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    On 2002-03-02 09:01, jgoulart wrote:
    I understand the mechanics of creating a shortcut on the destktop by hand or manually. But I'm trying to build a kind of installation program in excel VBA that will install the shortcut and quick launch. Anybody with ideas on code that creates a shortcut and taskbar launch button?

    John

  6. #6
    Board Regular
    Join Date
    Feb 2002
    Location
    Chippenham, UK
    Posts
    136
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    On 2002-03-02 09:01, jgoulart wrote:
    I understand the mechanics of creating a shortcut on the destktop by hand or manually. But I'm trying to build a kind of installation program in excel VBA that will install the shortcut and quick launch. Anybody with ideas on code that creates a shortcut and taskbar launch button?

    John
    Have you thought of making the desktop shortcut and incorporating that into an exe file, rather than trying to make VBA create one from scratch?

    C:WINDOWSDesktop - for your desktop shortcut

    and

    C:WINDOWSApplication DataMicrosoftInternet ExplorerQuick Launch - for your taskbar shortcut.



    _________________
    Regards,

    Gary Hewitt-Long



    [ This Message was edited by: gplhl on 2002-03-02 18:08 ]

  7. #7
    Board Regular
    Join Date
    Feb 2002
    Location
    John G
    Posts
    62
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    That sounds like a good idea of making it an .exe instead of vba. Do you have any advice on where I can go to learn how to do that?
    Thanks,

    John

  8. #8
    MrExcel MVP Ivan F Moala's Avatar
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    4,209
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    On 2002-03-02 20:32, jgoulart wrote:
    That sounds like a good idea of making it an .exe instead of vba. Do you have any advice on where I can go to learn how to do that?
    Thanks,

    John
    To create a short cut try this code;
    Note: If working from another workbook then
    remove the ' for the appropriate commands
    in the routine Create_Shortcut.

    If you need an explanation about the code then post......

    Ivan
    Option Explicit

    Declare Function SHGetSpecialFolderLocation Lib "Shell32" _
    (ByVal hwnd As Long, ByVal nFolder As Long, ppidl As Long) As Long

    Declare Function SHGetPathFromIDList Lib "Shell32" _
    (ByVal Pidl As Long, ByVal pszPath As String) As Long

    Declare Function SetWindowPos Lib "User32" _
    (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, _
    ByVal X As Long, ByVal Y As Long, ByVal cx As Long, _
    ByVal cy As Long, ByVal uFlags As Long) As Long

    Declare Function SetForegroundWindow Lib "User32" _
    (ByVal hwnd As Long) As Long

    Declare Function GetForegroundWindow Lib "User32" () As Long

    Dim ShortCutExists As Boolean
    Dim F_Lnk As String
    '

    Function CreateShortCut(Target As String) As Boolean

    Dim hwnd As Long 'Handle of Window
    Dim Pidl As Long
    Dim DeskTopSysFile As String

    'File exists
    If Dir(Target) = "" Then Exit Function

    'Get the windows desktop Pidl
    SHGetSpecialFolderLocation 0, 0, Pidl

    'assign spaces
    DeskTopSysFile = Space(260)

    'Get the path
    SHGetPathFromIDList Pidl, DeskTopSysFile

    'Now shorten
    DeskTopSysFile = Left(DeskTopSysFile, InStr(1, DeskTopSysFile, vbNullChar) - 1)

    'Does Shortcut exist
    If Dir(DeskTopSysFile & "" & F_Lnk) <> "" Then ShortCutExists = True: Exit Function

    hwnd = GetForegroundWindow
    SetWindowPos hwnd, -1, 0, 0, 0, 0, 3

    'Run RunDll32.exe - appWiz.Cpl = simulate Right click / Add shortcut
    Shell "RunDLL32 AppWiz.Cpl,NewLinkHere " & DeskTopSysFile & ""

    'Use send keys to send to ACTIVE application window
    SendKeys """" & Target & """~~", True
    SetForegroundWindow hwnd

    CreateShortCut = True

    End Function

    Sub Create_Shortcut()
    Dim ThisFile As String

    'ThisFile = ActiveWorkbook.Path & "" & ActiveWorkbook.Name
    ThisFile = ThisWorkbook.Path & "" & ThisWorkbook.Name
    'F_Lnk = Left(ActiveWorkbook.Name, Len(ActiveWorkbook.Name)) & ".LNK"
    F_Lnk = Left(ThisWorkbook.Name, Len(ThisWorkbook.Name)) & ".LNK"

    ' Creates a shortcut to your file ThisFile
    MsgBox IIf(CreateShortCut(ThisFile), "CreateShortCut created for: " & ThisFile, _
    IIf(ShortCutExists, "Shortcut Already created!", "Can't find the file!"))

    End Sub

  9. #9
    Board Regular
    Join Date
    Feb 2002
    Location
    Chippenham, UK
    Posts
    136
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    On 2002-03-02 20:32, jgoulart wrote:
    That sounds like a good idea of making it an .exe instead of vba. Do you have any advice on where I can go to learn how to do that?
    Thanks,

    John
    For simple EXE files take a look at WINZIP.


    Regards,

    Gary Hewitt-Long

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

 

 
DMCA.com