VBScript to run VBA

C

Chip

I am quite adept with VBA but need to use some VBScript. I will be inserting
script into an application using Web HMI. I need to call VBA procedures from
an Access Database. I gave it one quick stab but got errors. I am clueless at
this point.
 
D

Dave Patrick

Maybe this helps.

Dim appAccess, strConPathToDB

strConPathToDB = "D:\data\Access\db1.mdb"
Set appAccess = CreateObject("Access.Application.10")
' appAccess.Visible = True
appAccess.OpenCurrentDatabase strConPathToDB
appAccess.DoCmd.OpenModule "Module1", "SomeProc"
appAccess.Quit
Set appAccess = Nothing

--
Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

:
|I am quite adept with VBA but need to use some VBScript. I will be
inserting
| script into an application using Web HMI. I need to call VBA procedures
from
| an Access Database. I gave it one quick stab but got errors. I am clueless
at
| this point.
 
D

Dirk Goldgar

Dave Patrick said:
Maybe this helps.

Dim appAccess, strConPathToDB

strConPathToDB = "D:\data\Access\db1.mdb"
Set appAccess = CreateObject("Access.Application.10")
' appAccess.Visible = True
appAccess.OpenCurrentDatabase strConPathToDB
appAccess.DoCmd.OpenModule "Module1", "SomeProc"
appAccess.Quit
Set appAccess = Nothing

Note that the OpenModule method, as used in the line:
appAccess.DoCmd.OpenModule "Module1", "SomeProc"

does *not* run procedure "SomeProc" in module "Module1". All it does is
open that module, positioned at that procedure, in the VB editor.

You might get farther by replacing that line with one like this:

appAccess.Run "SomeProc"

Lookup "Run Method" in the online help for more information.
 
J

John Nurick

Hi Chip,

Automating Access is a bit more complicated than automating the average
Office app, especially if it's for unattended server-side use. See the
following articles

Using Microsoft Access as an Automation Server
http://support.microsoft.com/?id=147816
http://support.microsoft.com/?id=210111 (Access 2000 and later)

Considerations for Server-Side Automation of Office:
http://support.microsoft.com/?id=257757

Configure Office Applications to Run Under a Specific User Account
http://support.microsoft.com/?id=288367
 
D

Dave Patrick

Thanks. Of course you're correct. I should have looked at that closer.

--
Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

:
| Note that the OpenModule method, as used in the line:
|
| > appAccess.DoCmd.OpenModule "Module1", "SomeProc"
|
| does *not* run procedure "SomeProc" in module "Module1". All it does is
| open that module, positioned at that procedure, in the VB editor.
|
| You might get farther by replacing that line with one like this:
|
| appAccess.Run "SomeProc"
|
| Lookup "Run Method" in the online help for more information.
|
| --
| Dirk Goldgar, MS Access MVP
| www.datagnostics.com
|
| (please reply to the newsgroup)
|
|
 
C

Chip

Thanks to All. I managed to run 4 scripts from the other application that do
exactly what I wanted. I'll continu digging in.
 
Top