Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access_asp thread: Running access macro via asp pages using vbscript


Message #1 by "Jeff Forrester" <jforrester@g...> on Thu, 10 Oct 2002 15:20:32
I am trying to run a macro from an access database that is located on a 
web server. This macro is supposed to upload a fixed with text file, using 
specs into a pre-existing table in the database. I have been trying to 
find the answer but have been unable to find any help. If you know of a 
way to run a macro using vbscript from an asp page, I would appreciate any 
help.

This is an example of some of the code I have tried to so far:
<%
dbPath = server.mappath("ourpath\-fpdb\ncci.mdb")
macro = "ImportMacro" 

response.write runMacro(dbPath,macro)


function runMacro(byval dbPath, byval macroName) 
  'on error resume next
	Dim A 
	Set A = CreateObject("Access.Application") 
	A.Visible = true 
	A.OpenCurrentDatabase(dbPath) 
	A.Run macroName
	if err.number <> 0 then
	  runMacro = "Errors:" & err.description & "<br>"
	else
	  runMacro = "Successful Execution of: " & macroName & " in " & 
dbpath
	end if
	a.CloseCurrentDatabase
	a.application.Quit
	set a = nothing
End function 
%>
Let me know if you have any thoughts. Thanks
Message #2 by "Larry Woods" <larry@l...> on Thu, 10 Oct 2002 13:49:06 -0700
This may be a "obvious" question, but are you sure that Access is
installed on the server?  Just because you can use ADO to access
a Jet-based database does NOT mean that Access is installed on
the server.

Apologies if this is something that you already know...

Larry Woods


> -----Original Message-----
> From: Jeff Forrester [mailto:jforrester@g...]
> Sent: Thursday, October 10, 2002 3:21 PM
> To: Access ASP
> Subject: [access_asp] Running access macro via asp
> pages using vbscript
>
>
> I am trying to run a macro from an access database
> that is located on a
> web server. This macro is supposed to upload a fixed
> with text file, using
> specs into a pre-existing table in the database. I
> have been trying to
> find the answer but have been unable to find any help.
> If you know of a
> way to run a macro using vbscript from an asp page, I
> would appreciate any
> help.
>
> This is an example of some of the code I have tried to so far:
> <%
> dbPath = server.mappath("ourpath\-fpdb\ncci.mdb")
> macro = "ImportMacro"
>
> response.write runMacro(dbPath,macro)
>
>
> function runMacro(byval dbPath, byval macroName)
>   'on error resume next
> 	Dim A
> 	Set A = CreateObject("Access.Application")
> 	A.Visible = true
> 	A.OpenCurrentDatabase(dbPath)
> 	A.Run macroName
> 	if err.number <> 0 then
> 	  runMacro = "Errors:" & err.description & "<br>"
> 	else
> 	  runMacro = "Successful Execution of: " &
> macroName & " in " &
> dbpath
> 	end if
> 	a.CloseCurrentDatabase
> 	a.application.Quit
> 	set a = nothing
> End function
> %>
> Let me know if you have any thoughts. Thanks

Message #3 by "Jose Bueno" <jbueno@i...> on Fri, 11 Oct 2002 22:13:34
Here's your answer... this was tripping me up for the longest time.

http://support.microsoft.com/default.aspx?scid=kb;en-us;Q288368


  Return to Index