+ Reply to Thread
Results 1 to 4 of 4

Desktop shortcut

  1. #1
    Greg
    Guest

    Desktop shortcut

    Hi all

    Is it possible to have the activeworkbook when it saves for the very first
    time to automatically put a shortcut onto the desktop?

    I can work out how to have the code activate for the first time, just not
    how to get a shortcut to the desktop

    Thanks

    Greg



  2. #2
    Norman Jones
    Guest

    Re: Desktop shortcut

    Hi Greg,

    > I can work out how to have the code activate for the first time, just not
    > how to get a shortcut to the desktop


    Try:

    '=============>>
    Public Sub Tester()
    Dim WSH As Object
    Dim MyShortCut As Object
    Dim destPath As String
    Dim srcPath As String

    srcPath = ThisWorkbook.FullName

    Set WSH = CreateObject("WScript.Shell")
    destPath = WSH.SpecialFolders.Item("Desktop")

    Set MyShortCut = WSH.CreateShortcut(destPath & "\Test.lnk")
    With MyShortCut
    .TargetPath = srcPath
    .Save
    End With
    Set WSH = Nothing
    End Sub
    '<<=============


    ---
    Regards,
    Norman


    "Greg" <[email protected]> wrote in message
    news:[email protected]...
    > Hi all
    >
    > Is it possible to have the activeworkbook when it saves for the very first
    > time to automatically put a shortcut onto the desktop?
    >
    > I can work out how to have the code activate for the first time, just not
    > how to get a shortcut to the desktop
    >
    > Thanks
    >
    > Greg
    >
    >




  3. #3
    Greg
    Guest

    Re: Desktop shortcut

    Thanks Norman Exactly what I was hoping for

    Greg
    "Norman Jones" <[email protected]> wrote in message
    news:[email protected]...
    > Hi Greg,
    >
    >> I can work out how to have the code activate for the first time, just not
    >> how to get a shortcut to the desktop

    >
    > Try:
    >
    > '=============>>
    > Public Sub Tester()
    > Dim WSH As Object
    > Dim MyShortCut As Object
    > Dim destPath As String
    > Dim srcPath As String
    >
    > srcPath = ThisWorkbook.FullName
    >
    > Set WSH = CreateObject("WScript.Shell")
    > destPath = WSH.SpecialFolders.Item("Desktop")
    >
    > Set MyShortCut = WSH.CreateShortcut(destPath & "\Test.lnk")
    > With MyShortCut
    > .TargetPath = srcPath
    > .Save
    > End With
    > Set WSH = Nothing
    > End Sub
    > '<<=============
    >
    >
    > ---
    > Regards,
    > Norman
    >
    >
    > "Greg" <[email protected]> wrote in message
    > news:[email protected]...
    >> Hi all
    >>
    >> Is it possible to have the activeworkbook when it saves for the very
    >> first time to automatically put a shortcut onto the desktop?
    >>
    >> I can work out how to have the code activate for the first time, just not
    >> how to get a shortcut to the desktop
    >>
    >> Thanks
    >>
    >> Greg
    >>
    >>

    >
    >




  4. #4
    Forum Contributor
    Join Date
    11-20-2005
    Posts
    256
    Quote Originally Posted by Norman Jones
    Hi Greg,

    > I can work out how to have the code activate for the first time, just not
    > how to get a shortcut to the desktop


    Try:

    '=============>>
    Public Sub Tester()
    Dim WSH As Object
    Dim MyShortCut As Object
    Dim destPath As String
    Dim srcPath As String

    srcPath = ThisWorkbook.FullName

    Set WSH = CreateObject("WScript.Shell")
    destPath = WSH.SpecialFolders.Item("Desktop")

    Set MyShortCut = WSH.CreateShortcut(destPath & "\Test.lnk")
    With MyShortCut
    .TargetPath = srcPath
    .Save
    End With
    Set WSH = Nothing
    End Sub
    '<<=============


    ---
    Regards,
    Norman
    Hi Norman,
    For me, this code does not create a shortcut on the desktop, but instead here:

    C:\Documents and Settings\Owner\Application Data\Microsoft\Office\Recent

    Why is that?
    Thx
    Dave
    "The game is afoot Watson"

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1