Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Visual Basic (Microsoft) Versions 5/6 FAQ

Code Links

Creating a shortcut by kaiana
Posted: 12 Feb 03

Thanks to everyone for your support. The following code gave me my first star and it was a good feeling to help somone else, so now I give stars even to old links. Anything that helps me. Once again Thanks everyone.

Create a form with a yes and no buttons
make reference to 'Windows Script Host Object Model'Its near the end

paste the following code

Private Sub Command1_Click()
' yes click
    CreateMyShortcut "C:\Program Files\PERT", "PERT.lnk"
End Sub

Private Sub Command2_Click()
' no click
End Sub


Create a new module and paste the following

Option Explicit

Public Sub CreateMyShortcut(strTarget As String, strShortCutName As String, Optional strStartIn As String = "", Optional strArguments As String = "")
    Dim wsh As Object
    Dim sf As Object
    Dim Shortcut As Object
    Set wsh = CreateObject("wscript.shell")
    Set sf = wsh.SpecialFolders
' Creates shortcut on desktop
    Set Shortcut = wsh.CreateShortcut(sf("AllUsersDesktop") & "\" & strShortCutName)
    Shortcut.TargetPath = "C:\Program Files\Common Files\Microsoft Shared\Access Runtime\Office10\MSACCESS.EXE"
    Shortcut.IconLocation = "C:\Program Files\PERT\pert.ico"
    Shortcut.WorkingDirectory = "C:\Program Files\PERT\"
    Shortcut.Arguments = "C:\Program Files\PERT\PERT.mdb"
' Creates shortcut in statrup
    Set Shortcut = wsh.CreateShortcut(sf("AllUsersStartup") & "\" & strShortCutName)
    Shortcut.TargetPath = "C:\Program Files\PERT\PERT.mdb"
    Shortcut.IconLocation = "C:\Program Files\PERT\pert.ico"
    Shortcut.WorkingDirectory = "C:\Program Files\PERT\"
    Shortcut.Arguments = strArguments

End Sub


Let me know if this helps anyone

I would like to thank all members of this forum for all your priceless information.

Back to Visual Basic (Microsoft) Versions 5/6 FAQ Index
Back to Visual Basic (Microsoft) Versions 5/6 Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close