Application.FileOpenEx method (Project)

Opens a project or imports data.

Syntax

expression.FileOpenEx (Name, ReadOnly, Merge, TaskInformation, Table, Sheet, NoAuto, UserID, DatabasePassWord, FormatID, Map, openPool, Password, WriteResPassword, IgnoreReadOnlyRecommended, XMLName, DoNotLoadFromEnterprise)

expression A variable that represents an Application object.

Parameters

Name Required/Optional Data type Description
Name Optional String The name of the project file, source file, or data source to open. If Name is not specified, Project displays the Open dialog box.
ReadOnly Optional Boolean True if the file is opened read-only. If selectively importing data instead of loading a complete project, ReadOnly is ignored.
Merge Optional Long Specifies whether to automatically merge the file (MPX and XMLDOM formats only) with the active project. To automatically merge XLS, CSV, or TXT file formats, you can set the merge key in the import map that you are using. The Map argument should be used in place of Merge, which is included for backward compatibility. If Map is specified, Merge is ignored. Can be one of the PjMergeType constants. The default value is pjDoNotMerge.
TaskInformation Optional Boolean True if the file contains information about tasks for a project saved under a non-Project file format. False if the file contains information about resources. The Map argument should be used in place of TaskInformation, which is included for backward compatibility. If Map is specified, TaskInformation is ignored. The default value is True if the active view is a task view; otherwise it is False.
Table Optional String The name of a table in which to place the resource or task information for a project saved under a non-Project file format. Table is required if the value of the Merge argument is pjMerge. The Map argument should be used in place of Table, which is included for backward compatibility. If Map is specified, or Name specifies a database file or format, Table is ignored. The default value for Table is the name of the active table.
Sheet Optional String The sheet to read when opening a workbook created in Excel version 5.0 or later. The Map argument should be used in place of Sheet, which is included for backward compatibility. If Map is specified, or if the file specified by Name is not an Excel file, Sheet is ignored.
NoAuto Optional Boolean True if any Auto_Open macro is prevented from running. The default value is False.
UserID Optional String A user ID to use when accessing a database. If Name or FormatID is not a database, UserID is ignored.
DatabasePassWord Optional String A password to use when accessing a database. If Name or FormatID is not a database, DatabasePassWord is ignored.
FormatID Optional String Specifies the file or database format to use. If Project recognizes the format of the file specified with Name, FormatID is ignored. FormatID can be one of the values in the Format strings table.
Map Optional String The name of the import/export map to use when importing data.
openPool Optional Long The action to take when opening a resource pool or sharer file. When opening a master project, the value for openPool is also applied to the subprojects. Can be one of the PjPoolOpen constants. The default value is pjPromptPool.
Password Optional String A password to use when opening password-protected project files. If Password is incorrect or omitted and a file requires a password, the user is prompted for the password.
WriteResPassword Optional String A password to use when writing to a write-reserved project file. If WriteResPassword is omitted and the file requires a password, the user is prompted for the password.
IgnoreReadOnlyRecommended Optional BooleanVariant True to prevent Project from displaying an alert that the project should be opened read-only. If the project was not saved with a read-only recommendation, IgnoreReadOnlyRecommended is ignored.
XMLName Optional Variant This is the XML DOM object that is passed to the function when FormatID is MSProject.XML. The FileSaveAs method fails if the XML format is specified and XMLName is not a valid XML DOM object. If FormatID is anything other than MSProject.XML, XMLName should be NULL and the method should fail otherwise. Only one of XMLName or Name can be specified.
DoNotLoadFromEnterprise Optional Boolean True, if the project is not to be opened from Project Server. The default is False, where Project Professional opens the file from Project Server, or from the local computer if Project Professional is not logged on Project Server.

Format strings

Format string Description
"MSProject.mpp" Project file
"MSProject.mpt" Project template
"MSProject.mpp.8" Project 98 file
"MSProject.mpp.9" Project 2000–Project 2003 file
"MSProject.mpp.12" Project 2007 file
"MSProject.odbc" Open a project from an ODBC database
"MSProject.xls" Excel workbook
"MSProject.xls5" Excel 97–Excel 2003 workbook
"MSProject.pdf" PDF file
"MSProject.xpf" XPF file
"MSProject.csv" CSV (comma delimited) file
"MSProject.txt" TXT (tab delimited) file
"MSProject.xml" Project XML file

Return value

Boolean

Remarks

Using the FileOpenEx method without specifying any arguments displays the Open dialog box with the list of enterprise projects if Project Professional is logged on Project Server. Using FileOpenEx DoNotLoadFromEnterprise:=True displays the Open dialog box for project files on the local computer.

If you use the FileOpenEx method to open a project that is published to Project Server, it opens the file from the Draft database. For example, to programmatically open a project named Project1 as read/write from Project Server, use the following command: Application.FileOpenEx Name:="<>\Project1".

If you do not want to modify a project, set the ReadOnly parameter to True. For example, to open Project2 as read-only, use the following command: Application.FileOpenEx Name:="<>\Project2", ReadOnly:=True. To save the file in the Draft database, use the Application.FileSave method. To publish the file from the Draft to the Published database, so that changes are shown to other users, use the Application.Publish method.

The Name parameter can contain a file name string or an ODBC data source name (DSN) and project name string. The syntax for a data source is \Projectname. The less than (<) and greater than (>) symbols must be included, and a backslash ( \ ) must separate the data source name from the project name. DataSourceName itself can either be one of the ODBC data source names installed on the computer or a path and file name for a file-based database.

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.