473,320 Members | 1,900 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

VBS shortcut creator

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?
Jul 21 '08 #1
5 3742
"evenlater" <ev*******@gmail.comwrote in message
news:1c**********************************@m73g2000 hsh.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?
Try this: open your script from a shortcut which specifies a 'start in'
folder. Then, in your script you can pick up the location via the CurDir
function:

MyVariable = CurDir

You will then have the correct location in MyVariable.
Jul 21 '08 #2
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
Jul 21 '08 #3
I tried creating a shortcut to the script but I can't seem to get
CurDir to work. I'm trying

MsgBox CurDir

and I'm getting a box with no message... ?
On Jul 21, 11:29 am, "Stuart McCall" <smcc...@myunrealbox.comwrote:
Try this: open your script from a shortcut which specifies a 'start in'
folder. Then, in your script you can pick up the location via the CurDir
function:

MyVariable = CurDir

You will then have the correct location in MyVariable.
On Jul 21, 11:29 am, "Stuart McCall" <smcc...@myunrealbox.comwrote:
"evenlater" <evanca...@gmail.comwrote in message
Try this: open your script from a shortcut which specifies a 'start in'
folder. Then, in your script you can pick up the location via the CurDir
function:

MyVariable = CurDir

You will then have the correct location in MyVariable.
Jul 22 '08 #4
This code does tell me where the front-end of the application is when
run from that database, but I'm hoping to identify the file location
of the VBS script. Any ideas?

On Jul 21, 12:05 pm, lyle fairfield <lylef...@yah00.cawrote:
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
Jul 22 '08 #5
JvC
Left(CurrentDB.Name, InStrRev(CurrentDB.Name, "\"))

After serious thinking evenlater wrote :
This code does tell me where the front-end of the application is when
run from that database, but I'm hoping to identify the file location
of the VBS script. Any ideas?

On Jul 21, 12:05 pm, lyle fairfield <lylef...@yah00.cawrote:
>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

Jul 22 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

27
by: aa | last post by:
Thought this question might be out of this NG's scope, there are always knowledgable people who might hava an answer. A hyperlink to a shortcut to a file returnes an empty screen, and the source...
1
by: Stefan Ram | last post by:
Some style guides suggest to repeat a DC.creator meta-element for multiple authors, but doesn't this contradict its specification? "An entity primarily responsible for making the content of the...
1
by: Gorilla | last post by:
I bound my package with EXPLAIN(YES), and it's got the following static SQL in it: EXEC SQL SELECT CARDF, RECLENGTH INTO :CARDF,:RECLENGTH FROM SYSIBM.SYSTABLES WHERE NAME = :TBNAME AND...
4
by: Salad | last post by:
A97. If you set a forms properties to ShortcutMenu = No, the entire form is disabled from displaying a shortcut menu. If you set the property to Yes, all controls have a shortcut menu. I have...
0
by: cefrancke | last post by:
I recently discovered, that if you set the startup options for "security", you will have alot of work do to get Access back to "normal". If you disable the built-in menus/toolbars you'll have to...
0
by: Marcel | last post by:
Hi, the application I am writing has a MainMenu and a DataGrid (UltraGrid). Now I have to edit the text of each cell in this grid. So far so good. All works fine in editmode but if I press a...
4
by: I_AM_DON_AND_YOU? | last post by:
There is one more problem I am facing but didn't get the solution. In my Setup Program I am not been able to create 2 things (when the program is intalled on the client machine ) : (1) create...
7
by: GrandpaB | last post by:
I would appreciate assistance learning how to create a Desktop shortcut in my setup project. In the left pane of the Setup/File System window I right-clicked User's Desktop. From the contex...
0
by: Roshan | last post by:
Hi, I am trying to programatically add a FileSystemAccessRule for CREATOR OWNER to the filesystemsecurity obj of a folder whose creator and owner is a user account say 'SomeUser'. The rule gets...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.