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 strongm 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 Problem 1

Status
Not open for further replies.

emergencyplan

Technical User
Aug 19, 2003
34
GB
Hello I am using the following code to create a shortcut to a secured access database:

Dim objShell As WshShell
Dim objShortCut As WshShortcut

'initialize the object wshshell
Set objShell = New WshShell

'initialize the object WshShortcut
Set objShortCut = objShell.CreateShortcut("C:\Documents and Settings\Laurence\Desktop\NewShortCut.lnk")

objShortCut.TargetPath = "C:\Program Files\Microsoft Office\Office\MSACCESS.EXE" & "E:\My Documents\Access\Emerg Staff Contacts\Emerg Staff Original.mdb" & "/WRKGRP" & "E:\My Documents\Access\Emerg Staff Contacts\Secured.mdw"

objShortCut.IconLocation = "E:\My Documents\Images\Icons\Penfold.ico"

'save the shortcut
objShortCut.Save

My problem is that the target for the shortcut should read as follows; "C:\Program Files\Microsoft Office\Office\MSACCESS.EXE" "E:\My Documents\Access\Emerg Staff Contacts\Emerg Staff Original.mdb" /WRKGRP "E:\My Documents\Access\Emerg Staff Contacts\Secured.mdw". Therefore currently it is not working. Notice the missing "" around \WRKGRP.

Does anyone have any suggestion how to make this work. Many thanks.
 
Try using..

& """" & "/WRKGRP" & """" &

objShortCut.TargetPath = "C:\Program Files\Microsoft Office\Office\MSACCESS.EXE" & "E:\My Documents\Access\Emerg Staff Contacts\Emerg Staff Original.mdb" & """" & "/WRKGRP" & """" & "E:\My Documents\Access\Emerg Staff Contacts\Secured.mdw"
 
You are creating the shortcut wrong. Only "C:\Program Files\Microsoft Office\Office\MSACCESS.EXE" is the path. The rest is/are the arguments. So what you want is:
[tt]
objShortCut.TargetPath="C:\Program Files\Microsoft Office\Office\MSACCESS.EXE"
objShortCut.Arguments="""E:\My Documents\Access\Emerg Staff Contacts\Emerg Staff Original.mdb"" /WRKGRP ""E:\My Documents\Access\Emerg Staff Contacts\Secured.mdw"""
[/tt]
Note that this should also fix the / to \ problem that you mention in your other thread
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top