Execute vba code without opening Access

  • Thread starter Thread starter WC Justice
  • Start date Start date
W

WC Justice

Can I run a vba procedure from a command line which will execute without
opening Access?
 
No, you can't. In fact, you can't even run a VBA procedure from a command
line even if you do open Access.

What you can do is specify a macro to run when you open Access, and have
that macro call your VBA function (must be a Function, not a Sub)
 
Thanks, you saved me a lot of time. With that in mind, I should be able to
do this:

Use a command line to open the database, which includes a startup form with
an OnOpen procedure that does its business and then exits Access.

That is a crude way of accomplishing the objective, but is there any reason
to believe that it won't work?
 
That should work fine. A lot of people do just that through Windows
Scheduler to automate applications.
 
Nope. That will work. You can do it with a startup form, a macro called
autoexec, or by using the /x switch when starting Access which allows you to
specify a specific macro to run.
 
PC Datasheet said:
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
Over 1125 users have come to me from the newsgroups requesting help
(e-mail address removed)

--
To Steve:
Over 400 users from the newsgroups have visited the website to read what kind of a 'resource' you are...

To the original poster:

Most people here have a common belief that the newsgroups are for *free exchange of information*.
But Steve is a notorious job hunter in these groups, always trying to sell his services.
Also he gives LOTS of stupid or wrong answers.

Before you intend to do business with him look at:
http://home.tiscali.nl/arracom/whoissteve.html

Arno R
 
To the original poster:

It is commonly accepted that these newsgroups are for free exchange of
information. Please be aware that PC Datasheet is a notorious job hunter.
If you are considering doing business with him then I suggest that you take
a look at the link below first.


http://home.tiscali.nl/arracom/whoissteve.html
 
Use a command line to open the database, which includes a startup form
with
an OnOpen procedure that does its business and then exits Access.

in the dos days, we used what is called a batch file. In windows, we use
what is called windows scripting.

So, to make a window script, do the following

create a new notepad file....

lets call it mybatch.txt

Type in the following code....


dim accessApp

msgbox "Click ok to run batch job",64

set accessApp = createObject("Access.Application")

accessApp.OpenCurrentDataBase("C:\Documents and Settings\Albert\My
Documents\Access\ScriptExample\MultiSelect.mdb")

accessApp.Run "TimeUpDate"

accessApp.Quit

set accessApp = nothing

msgbox "Job complete", 64

now, save the above text file.

Renme the file extension to .vbs

At this point, you will see the icon of the file as a windows script. Click
on the file...it will run your script..and that script will run a sub in a
public module call TimeUpDate.

Of course, if you use the windows scheduler...you will remove the two
message box commands.


and, remember, you need to have file extensions visible to rename the
file...(but, that is always the first thing I do when I get a new windows
box).

So, just use a windows script to automate these things....
 
PC Datasheet said:
You can do it through Excel, Word or Outlook automation.


Cute answer. That will only work if the VBA code he wants to run has nothing
to do with Access. If it does, you then are opening Access from Excel, Word
or Outlook, thus opening two apps rather than one..

Either way, you still have to open an app that supports VBA.

John... Visio MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top