tags:

views:

95

answers:

2

Is it possible to call a VBA function (in Access) which takes two string parameters from the outside world (for instance from c# but others will do too)?

+1  A: 

There's a KB article on automating Access from C# which should get you started.

Stuart Dunkeld
+1  A: 

This is an example of a call from C# to an access database function that I have used in the past to create a similar feature.

private void btnRunVBAFunction_Click(object sender, System.EventArgs e)
{
Access.Application acApp = new Access.ApplicationClass();//create msaccess
application
acApp.OpenCurrentDatabase(@"C:\temp\db1.mdb",false ,null);//open mdb file
object oMissing = System.Reflection.Missing.Value;
//Run the Test macro in the module
acApp.Run("Test",ref oMissing,ref oMissing,ref oMissing,ref oMissing,
ref oMissing,ref oMissing,ref oMissing,ref oMissing,
ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing
,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing
,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing
,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing
,ref oMissing,ref oMissing);
acApp.Quit();//exit application
}

This is the site that I have used in the past.

http://bytes.com/topic/c-sharp/answers/255310-run-microsoft-access-module-vs-net-c

Irwin M. Fletcher
Thanks! That's exactly what I needed.
Max