Access macros from asp.net

G

Guest

I would like to run an Access Module in ASP.NET. I am using automation, and
I can access the data in the database, but when I try to run a macro (using
the late binding method), I get an exception that Access could not find the
macro I specified. My macro name is "JanList" but in the error message
Access said that it could not find "JanList. " Does the addition of a period
and space in the macro name string inidicate something about what I'm doing
wrong? Do I need to put some delimiter or something around the macro name?

Thanks in advance.
Stan
 
G

Guest

Here is the exception I got:
[COMException (0x800a09d5): Microsoft Access can't find the procedure
'JanMacro.']

Here is the code that caused it:
.......
Access.ApplicationClass oAccess = new Access.ApplicationClass();
oAccess.Visible = true;
oAccess.OpenCurrentDatabase(path, false, "");

// Run the macros.
RunMacro(oAccess, new Object[]{"JanMacro"});
......

private void RunMacro(object oApp, object[] oRunArgs)
{
oApp.GetType().InvokeMember("Run",
System.Reflection.BindingFlags.Default |
System.Reflection.BindingFlags.InvokeMethod,
null, oApp, oRunArgs);
}
 
B

Brendan Reynolds

This is just a guess on my part, but I note that the message says that
Access can't find "the procedure" rather than "the macro". Is your
automation code perhaps attempting to run a VBA procedure, rather than a
macro? (In case you didn't already know this, while the term 'macro' is
often used to refer to a VBA procedure in other Office applications, such as
Word and Excel, in Access macros are separate and very different objects
from VBA procedures).

--
Brendan Reynolds (MVP)

Stan Graziano said:
Here is the exception I got:
[COMException (0x800a09d5): Microsoft Access can't find the procedure
'JanMacro.']

Here is the code that caused it:
......
Access.ApplicationClass oAccess = new Access.ApplicationClass();
oAccess.Visible = true;
oAccess.OpenCurrentDatabase(path, false, "");

// Run the macros.
RunMacro(oAccess, new Object[]{"JanMacro"});
.....

private void RunMacro(object oApp, object[] oRunArgs)
{
oApp.GetType().InvokeMember("Run",
System.Reflection.BindingFlags.Default |
System.Reflection.BindingFlags.InvokeMethod,
null, oApp, oRunArgs);
}


Stan Graziano said:
I would like to run an Access Module in ASP.NET. I am using automation,
and
I can access the data in the database, but when I try to run a macro
(using
the late binding method), I get an exception that Access could not find
the
macro I specified. My macro name is "JanList" but in the error message
Access said that it could not find "JanList. " Does the addition of a
period
and space in the macro name string inidicate something about what I'm
doing
wrong? Do I need to put some delimiter or something around the macro
name?

Thanks in advance.
Stan
 
G

Guest

Very interesting. Can you suggest a process by which I can test this? I
don't know how to create a VBA procedure in Excel. If you are right, how do
I call the macro? Could I create a VBA procedure that calls the macro?

Brendan Reynolds said:
This is just a guess on my part, but I note that the message says that
Access can't find "the procedure" rather than "the macro". Is your
automation code perhaps attempting to run a VBA procedure, rather than a
macro? (In case you didn't already know this, while the term 'macro' is
often used to refer to a VBA procedure in other Office applications, such as
Word and Excel, in Access macros are separate and very different objects
from VBA procedures).

--
Brendan Reynolds (MVP)

Stan Graziano said:
Here is the exception I got:
[COMException (0x800a09d5): Microsoft Access can't find the procedure
'JanMacro.']

Here is the code that caused it:
......
Access.ApplicationClass oAccess = new Access.ApplicationClass();
oAccess.Visible = true;
oAccess.OpenCurrentDatabase(path, false, "");

// Run the macros.
RunMacro(oAccess, new Object[]{"JanMacro"});
.....

private void RunMacro(object oApp, object[] oRunArgs)
{
oApp.GetType().InvokeMember("Run",
System.Reflection.BindingFlags.Default |
System.Reflection.BindingFlags.InvokeMethod,
null, oApp, oRunArgs);
}


Stan Graziano said:
I would like to run an Access Module in ASP.NET. I am using automation,
and
I can access the data in the database, but when I try to run a macro
(using
the late binding method), I get an exception that Access could not find
the
macro I specified. My macro name is "JanList" but in the error message
Access said that it could not find "JanList. " Does the addition of a
period
and space in the macro name string inidicate something about what I'm
doing
wrong? Do I need to put some delimiter or something around the macro
name?

Thanks in advance.
Stan
 
B

Brendan Reynolds

Stan Graziano said:
Very interesting. Can you suggest a process by which I can test this?

Open the MDB and look? The database window has a list of categories of
objects (tables, queries, forms, reports, pages, macros, modules) down the
left hand side. If 'JanMacro' is a macro, it will be listed under 'macros'.
If it is a VBA procedure, it will be contained in one of the modules listed
under 'modules'. If there are many modules, rather than hunting through them
one at a time, open any one of them and use the Find dialog (on the Edit
menu) to search the current project for 'JanMacro'.
I
don't know how to create a VBA procedure in Excel.

In Excel, 'macro' and 'VBA procedure' are synonyms. Recording a macro
creates a VBA procedure. But you can also create a procedure without
recording, by selecting Macro, then VBA Editor, from the Tools menu.
If you are right, how do
I call the macro? Could I create a VBA procedure that calls the macro?

Sure. The VBA code is: DoCmd.RunMacro "YourMacroNameHere"

The code you posted appears to be server-side code? You do realize the
instance of Access that is created will be created on the server?

--
Brendan Reynolds (MVP)
Brendan Reynolds said:
This is just a guess on my part, but I note that the message says that
Access can't find "the procedure" rather than "the macro". Is your
automation code perhaps attempting to run a VBA procedure, rather than a
macro? (In case you didn't already know this, while the term 'macro' is
often used to refer to a VBA procedure in other Office applications, such
as
Word and Excel, in Access macros are separate and very different objects
from VBA procedures).

--
Brendan Reynolds (MVP)

Stan Graziano said:
Here is the exception I got:
[COMException (0x800a09d5): Microsoft Access can't find the procedure
'JanMacro.']

Here is the code that caused it:
......
Access.ApplicationClass oAccess = new Access.ApplicationClass();
oAccess.Visible = true;
oAccess.OpenCurrentDatabase(path, false, "");

// Run the macros.
RunMacro(oAccess, new Object[]{"JanMacro"});
.....

private void RunMacro(object oApp, object[] oRunArgs)
{
oApp.GetType().InvokeMember("Run",
System.Reflection.BindingFlags.Default |
System.Reflection.BindingFlags.InvokeMethod,
null, oApp, oRunArgs);
}


:

I would like to run an Access Module in ASP.NET. I am using
automation,
and
I can access the data in the database, but when I try to run a macro
(using
the late binding method), I get an exception that Access could not
find
the
macro I specified. My macro name is "JanList" but in the error
message
Access said that it could not find "JanList. " Does the addition of a
period
and space in the macro name string inidicate something about what I'm
doing
wrong? Do I need to put some delimiter or something around the macro
name?

Thanks in advance.
Stan
 
G

Guest

I have verified that the macro I wish to execute is indeed a macro, and not a
procedure.

So, in C#, is the first parameter of the InvokeMember function is supposed
to be "RunMacro" instead of "Run"? I attempted that, but now I get an
exception "System.Runtime.InteropServices.COMException: Unkown name".

How can I get the macro to execute? I'll try to create a procedure that
calls the macro, then call it.

I mistyped in my last message, I meant I don't know how to create VBA
procedures in Access. However, when I attempt to create a new module, I get
a message "You do not have exclusive access to the database at this time. If
you proceed to make changes, you may not be able to save them later". This
is on a development laptop that isn't even connected to a network right now.
How to I convince Access that I really am the only user?

Yes, I am aware that this is server-side code.

Thank you.
Stan

Brendan Reynolds said:
Stan Graziano said:
Very interesting. Can you suggest a process by which I can test this?

Open the MDB and look? The database window has a list of categories of
objects (tables, queries, forms, reports, pages, macros, modules) down the
left hand side. If 'JanMacro' is a macro, it will be listed under 'macros'.
If it is a VBA procedure, it will be contained in one of the modules listed
under 'modules'. If there are many modules, rather than hunting through them
one at a time, open any one of them and use the Find dialog (on the Edit
menu) to search the current project for 'JanMacro'.
I
don't know how to create a VBA procedure in Excel.

In Excel, 'macro' and 'VBA procedure' are synonyms. Recording a macro
creates a VBA procedure. But you can also create a procedure without
recording, by selecting Macro, then VBA Editor, from the Tools menu.
If you are right, how do
I call the macro? Could I create a VBA procedure that calls the macro?

Sure. The VBA code is: DoCmd.RunMacro "YourMacroNameHere"

The code you posted appears to be server-side code? You do realize the
instance of Access that is created will be created on the server?

--
Brendan Reynolds (MVP)
Brendan Reynolds said:
This is just a guess on my part, but I note that the message says that
Access can't find "the procedure" rather than "the macro". Is your
automation code perhaps attempting to run a VBA procedure, rather than a
macro? (In case you didn't already know this, while the term 'macro' is
often used to refer to a VBA procedure in other Office applications, such
as
Word and Excel, in Access macros are separate and very different objects
from VBA procedures).

--
Brendan Reynolds (MVP)

Here is the exception I got:
[COMException (0x800a09d5): Microsoft Access can't find the procedure
'JanMacro.']

Here is the code that caused it:
......
Access.ApplicationClass oAccess = new Access.ApplicationClass();
oAccess.Visible = true;
oAccess.OpenCurrentDatabase(path, false, "");

// Run the macros.
RunMacro(oAccess, new Object[]{"JanMacro"});
.....

private void RunMacro(object oApp, object[] oRunArgs)
{
oApp.GetType().InvokeMember("Run",
System.Reflection.BindingFlags.Default |
System.Reflection.BindingFlags.InvokeMethod,
null, oApp, oRunArgs);
}


:

I would like to run an Access Module in ASP.NET. I am using
automation,
and
I can access the data in the database, but when I try to run a macro
(using
the late binding method), I get an exception that Access could not
find
the
macro I specified. My macro name is "JanList" but in the error
message
Access said that it could not find "JanList. " Does the addition of a
period
and space in the macro name string inidicate something about what I'm
doing
wrong? Do I need to put some delimiter or something around the macro
name?

Thanks in advance.
Stan
 
G

Guest

I have gotten the macro to execute via COM through a procedure. Thank you!
The exclusive access sillyness was resolved by rebooting. Apparently even
though I close my COM object access, it is still holding on to a handle,
perhaps because I was using a debugger?

Now my problem is that the macro, which exports a query to a dbf file, is
placing the file two folders down from the location of the mdb file. I don't
see a way to specify path for the output. Any suggestions?

Stan Graziano said:
I have verified that the macro I wish to execute is indeed a macro, and not a
procedure.

So, in C#, is the first parameter of the InvokeMember function is supposed
to be "RunMacro" instead of "Run"? I attempted that, but now I get an
exception "System.Runtime.InteropServices.COMException: Unkown name".

How can I get the macro to execute? I'll try to create a procedure that
calls the macro, then call it.

I mistyped in my last message, I meant I don't know how to create VBA
procedures in Access. However, when I attempt to create a new module, I get
a message "You do not have exclusive access to the database at this time. If
you proceed to make changes, you may not be able to save them later". This
is on a development laptop that isn't even connected to a network right now.
How to I convince Access that I really am the only user?

Yes, I am aware that this is server-side code.

Thank you.
Stan

Brendan Reynolds said:
Stan Graziano said:
Very interesting. Can you suggest a process by which I can test this?

Open the MDB and look? The database window has a list of categories of
objects (tables, queries, forms, reports, pages, macros, modules) down the
left hand side. If 'JanMacro' is a macro, it will be listed under 'macros'.
If it is a VBA procedure, it will be contained in one of the modules listed
under 'modules'. If there are many modules, rather than hunting through them
one at a time, open any one of them and use the Find dialog (on the Edit
menu) to search the current project for 'JanMacro'.
I
don't know how to create a VBA procedure in Excel.

In Excel, 'macro' and 'VBA procedure' are synonyms. Recording a macro
creates a VBA procedure. But you can also create a procedure without
recording, by selecting Macro, then VBA Editor, from the Tools menu.
If you are right, how do
I call the macro? Could I create a VBA procedure that calls the macro?

Sure. The VBA code is: DoCmd.RunMacro "YourMacroNameHere"

The code you posted appears to be server-side code? You do realize the
instance of Access that is created will be created on the server?

--
Brendan Reynolds (MVP)
:

This is just a guess on my part, but I note that the message says that
Access can't find "the procedure" rather than "the macro". Is your
automation code perhaps attempting to run a VBA procedure, rather than a
macro? (In case you didn't already know this, while the term 'macro' is
often used to refer to a VBA procedure in other Office applications, such
as
Word and Excel, in Access macros are separate and very different objects
from VBA procedures).

--
Brendan Reynolds (MVP)

Here is the exception I got:
[COMException (0x800a09d5): Microsoft Access can't find the procedure
'JanMacro.']

Here is the code that caused it:
......
Access.ApplicationClass oAccess = new Access.ApplicationClass();
oAccess.Visible = true;
oAccess.OpenCurrentDatabase(path, false, "");

// Run the macros.
RunMacro(oAccess, new Object[]{"JanMacro"});
.....

private void RunMacro(object oApp, object[] oRunArgs)
{
oApp.GetType().InvokeMember("Run",
System.Reflection.BindingFlags.Default |
System.Reflection.BindingFlags.InvokeMethod,
null, oApp, oRunArgs);
}


:

I would like to run an Access Module in ASP.NET. I am using
automation,
and
I can access the data in the database, but when I try to run a macro
(using
the late binding method), I get an exception that Access could not
find
the
macro I specified. My macro name is "JanList" but in the error
message
Access said that it could not find "JanList. " Does the addition of a
period
and space in the macro name string inidicate something about what I'm
doing
wrong? Do I need to put some delimiter or something around the macro
name?

Thanks in advance.
Stan
 
G

Guest

I've resolved that problem too. This issue is closed. Thank you very much!

Stan Graziano said:
I have gotten the macro to execute via COM through a procedure. Thank you!
The exclusive access sillyness was resolved by rebooting. Apparently even
though I close my COM object access, it is still holding on to a handle,
perhaps because I was using a debugger?

Now my problem is that the macro, which exports a query to a dbf file, is
placing the file two folders down from the location of the mdb file. I don't
see a way to specify path for the output. Any suggestions?

Stan Graziano said:
I have verified that the macro I wish to execute is indeed a macro, and not a
procedure.

So, in C#, is the first parameter of the InvokeMember function is supposed
to be "RunMacro" instead of "Run"? I attempted that, but now I get an
exception "System.Runtime.InteropServices.COMException: Unkown name".

How can I get the macro to execute? I'll try to create a procedure that
calls the macro, then call it.

I mistyped in my last message, I meant I don't know how to create VBA
procedures in Access. However, when I attempt to create a new module, I get
a message "You do not have exclusive access to the database at this time. If
you proceed to make changes, you may not be able to save them later". This
is on a development laptop that isn't even connected to a network right now.
How to I convince Access that I really am the only user?

Yes, I am aware that this is server-side code.

Thank you.
Stan

Brendan Reynolds said:
Very interesting. Can you suggest a process by which I can test this?

Open the MDB and look? The database window has a list of categories of
objects (tables, queries, forms, reports, pages, macros, modules) down the
left hand side. If 'JanMacro' is a macro, it will be listed under 'macros'.
If it is a VBA procedure, it will be contained in one of the modules listed
under 'modules'. If there are many modules, rather than hunting through them
one at a time, open any one of them and use the Find dialog (on the Edit
menu) to search the current project for 'JanMacro'.

I
don't know how to create a VBA procedure in Excel.

In Excel, 'macro' and 'VBA procedure' are synonyms. Recording a macro
creates a VBA procedure. But you can also create a procedure without
recording, by selecting Macro, then VBA Editor, from the Tools menu.

If you are right, how do
I call the macro? Could I create a VBA procedure that calls the macro?

Sure. The VBA code is: DoCmd.RunMacro "YourMacroNameHere"

The code you posted appears to be server-side code? You do realize the
instance of Access that is created will be created on the server?

--
Brendan Reynolds (MVP)


:

This is just a guess on my part, but I note that the message says that
Access can't find "the procedure" rather than "the macro". Is your
automation code perhaps attempting to run a VBA procedure, rather than a
macro? (In case you didn't already know this, while the term 'macro' is
often used to refer to a VBA procedure in other Office applications, such
as
Word and Excel, in Access macros are separate and very different objects
from VBA procedures).

--
Brendan Reynolds (MVP)

Here is the exception I got:
[COMException (0x800a09d5): Microsoft Access can't find the procedure
'JanMacro.']

Here is the code that caused it:
......
Access.ApplicationClass oAccess = new Access.ApplicationClass();
oAccess.Visible = true;
oAccess.OpenCurrentDatabase(path, false, "");

// Run the macros.
RunMacro(oAccess, new Object[]{"JanMacro"});
.....

private void RunMacro(object oApp, object[] oRunArgs)
{
oApp.GetType().InvokeMember("Run",
System.Reflection.BindingFlags.Default |
System.Reflection.BindingFlags.InvokeMethod,
null, oApp, oRunArgs);
}


:

I would like to run an Access Module in ASP.NET. I am using
automation,
and
I can access the data in the database, but when I try to run a macro
(using
the late binding method), I get an exception that Access could not
find
the
macro I specified. My macro name is "JanList" but in the error
message
Access said that it could not find "JanList. " Does the addition of a
period
and space in the macro name string inidicate something about what I'm
doing
wrong? Do I need to put some delimiter or something around the macro
name?

Thanks in advance.
Stan
 

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

Top