本文介绍了调用从C#VBA函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能调用一个VBA函数(在Access),它从外面的世界有两个字符串参数(例如从C#,但其他人会做太多)?

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)?

推荐答案

这是从C#与我在过去曾用于创建一个类似的功能的Access数据库函数调用的一个例子。

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.

这篇关于调用从C#VBA函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-22 22:50