I am trying to do an automated xml export from an access database using C# and OLE. Everything is working perfectly except that the startup form is shown and won’t close without user intervention.
Here’s what I am doing so far:
objAccess = CreateObject('Access.Application'); objAccess.OpenCurrentDatabase('C:\\MYDB.mdb', true); //true = open in exclusive mode objAccess.ExportXML(0, 'TestTable', 'c:\\test.xml'); objAccess.CloseCurrentDatabase(); objAccess.Quit();
As far as I know the only way is to use the /nostartup switch on msaccess.exe
So you have to use shell command to get the access object
I have a function that opens a database and returns the object (This is VBA code which you will have to convert to C#)
EDIT: Here’s a link to some VB.NET code that does a similar thing. Scroll down to ‘Create the Complete Sample Visual Basic .NET Project’ and look for the ‘ShellGetDB’ function