devxlogo

Running an Access Macro from ASP

Running an Access Macro from ASP

Question:
It’s possible to run an Access macro from ASP?

Answer:
Although you can run a macro from Access, it takes preparation, nerve and luck.
Preparation, because you have to set Internet Information Server 4.0 to allow out of process applications and give your IUSR_machine plenty of rights in the system.
Nerve, because you may end up rebooting your web server if you run a macro that doesn’t behave or causes a sharing violation.
Lucky, because some macros run and some don’t. The error messages you get may not relate to what you are doing.

To experiment, I created an Access 97 macro called CreateHTML. The macro writes the contents of a table to an HTML file. The directory needs to be read-write. The macro has these properties:

Action: OutputTo
Object Type: Table
Object Name: Countries
Output Format: HTML (*.html)
Output File: e:inetpubwwwrootaccesscountries.htm
Auto Start: Yes

I used the following VBScript code in my ASP file:

set objAccess=server.createobject(“Access.application”)
objAccess.Visible=False
objAccess.OpenCurrentDatabase “e:inetpubwwwrootaccesssitelist.mdb”, true
objAccess.DoCmd.RunMacro “createHTML”
objAccess.CloseCurrentDatabase
set objAccess=Nothing

It appears that Visual Basic for Applications isn’t yet well-suited to the ASP environment. That may have to do with its threading model.

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist