Microsoft KB Archive/202039

= ACC2000: How to Programmatically Save a Database or Project as an MDE or ADE File =

Article ID: 202039

Article Last Modified on 10/11/2006

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q202039



Moderate: Requires basic macro, coding, and interoperability skills.



SUMMARY
This article describes how to programmatically create an MDE file from an existing database, or how to create an ADE file from an existing project.



MORE INFORMATION
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. You can use Microsoft Visual Basic for Applications to create an MDE file from your existing Microsoft Access database or create an ADE file from your existing Microsoft Access Project. You can run the following sample function from any database or any project, other than the database or project that you want to convert to an MDE file or an ADE file. This function has one argument, MyPath, which is the full path to the database or the project from which to create the MDE file or the ADE file.

NOTE: You can use the SendKeys method to bypass the dialog box. Although this method permits you to programmatically save a database or a project as an MDE file or an ADE file, this method may cause an errant "ENTER" to be processed somewhere in one of your programs or in your open files. Use this method with caution.   Create a new module, and then type the following function: Function GenerateMDEFile(MyPath As String)

Dim NAcc As Access.Application

Set NAcc = CreateObject("Access.Application")

'The following lines simulate accepting the default 'name, clicking Make MDE, and clicking Save SendKeys MyPath & "{Enter}{Enter}" SendKeys "{Enter}"

NAcc.DoCmd.RunCommand acCmdMakeMDEFile

Set NAcc = Nothing

End Function To run this function, follow these steps:

 Click Immediate Window on the View menu to open the Immediate window. Type ?GenerateMDEFile(), where  is the full path and the database name or the project name from which you want to create an MDE file or an ADE file. Press ENTER.

NOTE: The resulting MDE file or ADE file has the same name as the original database or original project.

