从C#调用VBA函数

5

是否可以从外部世界(例如来自C#,但其他语言也可以)调用Access中接受两个字符串参数的VBA函数?

2个回答

2
这是一个从C#调用访问数据库函数的示例,我曾在过去使用它来创建类似的功能。
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


1

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接