Call VBA function from C #

Is it possible to call a VBA function (in Access) that takes two string parameters from the outside world (for example, from C #, but others will do the same)?

+3
source share
2 answers

This is an example of a call from C # to an access database function that I used in the past to create a similar 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
}

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

+1
source

Here 's a KB article on access automation with C # that should get you started.

+1
source

Source: https://habr.com/ru/post/1723908/


All Articles