locked
Access autoexec from c# application RRS feed

  • Question

  • I am trying to open access application, my main objective is to run autoexec completely.. but it is not working properly

    here is my code

    static void Main(string[] args)
            {
                string filepath = Properties.Settings.Default.FilePath;
                Access.Application oAccess = new Access.Application();
                oAccess.Visible = true;
                oAccess.OpenCurrentDatabase(filepath, true);

                // Run the macros.
                //RunMacro(oAccess, new Object[] { "autoexec" });
                //RunMacro(oAccess, new Object[]{"DoKbTestWithParameter","Hello from C# Client."});

                // Quit Access and clean up.
                oAccess.DoCmd.Quit(Access.AcQuitOption.acQuitSaveNone);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(oAccess);
                oAccess = null;
        
            }
            private static void RunMacro(object oApp, object[] oRunArgs)
            {
                oApp.GetType().InvokeMember("Run",
                    System.Reflection.BindingFlags.Default |
                    System.Reflection.BindingFlags.InvokeMethod,
                    null, oApp, oRunArgs);
            }

    Thursday, January 28, 2016 12:03 PM

All replies

  • Are you using VSTO?  If so, you are in the wrong forum.
    Friday, January 29, 2016 12:55 AM