evenlater <ev*******@gmail.comwrote in news:1c6c48c2-c011-4399-96ef-
a7**********@m73g2000hsh.googlegroups.com:
I want to use a VBS script to create shortcuts to my Access 2007
application. I want the script to be able to discern its own file
location (that is, the location of the VBS script itself) so it can
create a shortcut to a front-end .accde stored in the same folder as
the script.
Can this be done?
This is a VBA script which does some of what you want. It should be
adaptable.
Sub temp()
Dim wd As String
Dim ws As Object
Dim sh As Object
Dim db As String
Dim tp As String
wd = Left$(DBEngine(0)(0).Name, Len(DBEngine(0)(0).Name) - Len(Dir
$(DBEngine(0)(0).Name)))
tp = SysCmd(acSysCmdAccessDir) & "msaccess.exe"
Set ws = CreateObject("WScript.Shell")
With ws
db = Dir$(wd & "\*.mdb")
Do While Len(db) 0
Set sh = .CreateShortcut("C:\Users\lyle fairfield\Desktop\" &
Left(db, InStr(db, ".")) & "lnk")
With sh
.TargetPath = tp
.WorkingDirectory = wd
.Arguments = """" & db & """"
.Save
End With
db = Dir$()
Loop
End With
Set sh = Nothing
Set ws = Nothing
End Sub