File shortcuts from VB in Access2000

  • Thread starter Thread starter pvp
  • Start date Start date
Is it possible to create a Windows file shortcut from VB
in Access 2000?

check out the CreateShortcut method of the WshShell object. It is part of
the Windows Script Host library, so you might have to hunt around a bit.

B Wishes


Tim F
 
Many thanks, TB. I ticked Windows Script Host in my
Access and modified the example from the MSDN site and it
worked like a dream!. For interest, the code looks like:

"
Sub createShortcut(sourceS As String, linkS As String,
targetS As String, iconS As String)

Dim shell As WshShell, strDesktop As String,
oShellLink As WshShortcut

' create shell
Set shell = New WshShell

' create shortcut and all its properties
Select Case sourceS
Case "DT"
Source = shell.SpecialFolders("Desktop")
Case "AUSM"
Source = shell.SpecialFolders("AllUsersStartMenu")
Case "SM"
Source = shell.SpecialFolders("StartMenu")
End Select

' if special directory was meaningless, go home
If Source <> "" Then
Set oShellLink = shell.createShortcut(Source &
linkS)
oShellLink.TargetPath = targetS
oShellLink.WindowStyle = 3 ' open maximised
'oShellLink.Hotkey = "CTRL+SHIFT+F"
oShellLink.IconLocation = iconS
'oShellLink.Description = "Shortcut Script"
'oShellLink.WorkingDirectory = strDesktop

' save the icon & kill objects
oShellLink.Save
Set oShellLink = Nothing
End If

Set oShell = Nothing

End Sub

"
 
Back
Top