Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a shortcut

Code Links

Creating a shortcut

by  kaiana  Posted    (Edited  )
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
End Sub
________________________________________________________

Private Sub Command2_Click()
' no click
End
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.Description = "DEVELOPED BY iASSIST SOFTWARE DEVELOPERS"
Shortcut.Arguments = "C:\Program Files\PERT\PERT.mdb"
Shortcut.Save

' 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
Shortcut.Save

End Sub

___________________________________________________________


Let me know if this helps anyone

I would like to thank all members of this forum for all your priceless information.
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top