UIApplication.OpenAndActivateDocument(String) Method

UIApplicationOpenAndActivateDocument(String) Method

Opens and activates a Revit document.

Namespace: Autodesk.Revit.UI
Assembly: RevitAPIUI (in RevitAPIUI.dll) Version: 25.3.0.0 (25.3.0.0)
Syntax
public UIDocument OpenAndActivateDocument(
	string fileName
)
Public Function OpenAndActivateDocument ( 
	fileName As String
) As UIDocument
public:
UIDocument^ OpenAndActivateDocument(
	String^ fileName
)
member OpenAndActivateDocument : 
        fileName : string -> UIDocument 

Parameters

fileName  String
A full path to a revit file to be opened. The file can be either a Revit project, template, or family document.

Return Value

UIDocument
The opened document.
Exceptions
ExceptionCondition
ArgumentException The given 'fileName' is not a Revit file (a project, template, or family document).
ArgumentNullException If is passed as 'fileName'. -or- A non-optional argument was null
FileArgumentNotFoundException The file specified by 'fileName' cannot be found.
InvalidOperationException
  • If the active document is currently modifiable.
  • If an API event handler is currently being executed.
RevitServerCommunicationException If there is any server internal error.
Remarks
This method, if successful, changes the active document. It is not allowed to have an open transaction in the active document when calling this method. Additionally, this method may not be called from inside an event handler.
See Also