[AccessD] Creating Shortcut On The Fly

Neal Kling nkling at co.montgomery.ny.us
Tue Feb 22 07:18:18 CST 2005


Here's a method that uses the Windows Scripting Host.

The library you need to add to your Access projects is "wshom.ocx", or
"wscript.exe" depending on what interface you want to use in your code. Both
perform the same functions, just at lower or higher levels, respectively.

Here's some sample code to add desktop shortcut from your Access/VBA
application:

Function foo()
   Dim o As New IWshShell_Class     '# scripting object shell
   Dim lnk As IWshShortcut_Class    '# shortcut class under shell object
   '# create shortcut on desktop. CHANGE THIS TO POINT TO YOUR
   '# DESKTOP FOLDER!
   Set lnk = o.CreateShortcut("C:\windows\profiles\nkling\desktop\test.lnk")
   '# set path to executable
   lnk.TargetPath = "c:\windows\notepad.exe"
   '# set window style and description
   lnk.WindowStyle = 3
   lnk.Description = "My New Link"
   '# save link
   lnk.Save
End Function

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of
paul.hartland at fsmail.net
Sent: Tuesday, February 22, 2005 6:50 AM
To: accessd
Subject: [AccessD] Creating Shortcut On The Fly


To all,

I am writing a little database application that will copy a set of files into a specified folder, what I then want to do is create a shortcut to one of the files using code and put it onto the desktop, anyone any ideas on how I would go about this ?

Thanks in advance for any help....

Paul Hartland

-- 

Whatever you Wanadoo:
http://www.wanadoo.co.uk/time/

This email has been checked for most known viruses - find out more at: http://www.wanadoo.co.uk/help/id/7098.htm
-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list