从C#调用VBA函数

是否可以调用VBA函数(在Access中),该函数从外部世界获取两个字符串参数(例如来自c#但其他人也会这样做)?

这是从C#调用访问数据库函数的一个示例,我过去使用它来创建类似的function。

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 } 

这是我过去使用过的网站。

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

有一篇关于从C#自动化Access的知识库文章应该可以帮助您入门。