I am trying to automate some tasks in MS Access which are involving some button presses. Here are my best guesses so far, but I never find a way to finally execute a click...
using Microsoft.Office.Interop.Access;
Application access = new Application();
access.OpenCurrentDatabase("SomeDatabaseName.accdb");
access.DoCmd.OpenForm("SomeFormName", AcFormView.acNormal);
access.DoCmd.GoToControl("SomeButtonName");
access.DoCmd... // I can go to the control, but how do I click it?
Or maybe there is another approach using the Microsoft.Office.Interop.Access.CommandButton
instance?
var form = access.Forms["SomeFormName"];
foreach (var control in form.Controls)
{
if (control is CommandButton button)
{
// I can get the CommandButton, but how do I execute the click procedure?
string onClick = button.OnClick; // it's just this string: "[Event Procedure]"
}
}
access.CloseCurrentDatabase();
access.Quit(AcQuitOption.acQuitSaveNone);
Is this possible using the MS Office Interop assemblies? Or are there any alternatives? Unfortunately, these interop assemblies are very poorly documented.