Click here to Skip to main content
15,891,253 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello guys

can anyone give me simple program on macro i write a below code

C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.Office.Interop.Access.Dao;
namespace WindowsFormsApplication2
{ public partial class Form1 : Form
    {public Form1()
        {InitializeComponent();}
        private void button1_Click(object sender, EventArgs e)
        {Microsoft.Office.Interop.Access.Application acApp = new Microsoft.Office.Interop.Access.Application();
            try{acApp.OpenCurrentDatabase(@"C:\Users\Administrator\Desktop\test.mdb",true);//open mdb file
                object oMissing = System.Reflection.Missing.Value;
                acApp.Run("Macro1", 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);}
            catch
            {}
            finally
            {acApp.Quit();//exit application}}}}

but it gives me an error that you cannot find the macro can you give me solution or code for that i use the access database or can you give me example code for using ms-access for C# .NET
Posted
Updated 19-Aug-13 19:31pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900