How to: Programmatically Open Visio Documents
There are two methods for opening existing Microsoft Office Visio documents: Open and OpenEx. The OpenEx method is identical to the Open method, except that it provides arguments in which the caller can specify how the document opens.
To open a Visio document
To open a Visio document as read-only and docked
Call the Microsoft.Office.Interop.Visio.Documents.OpenEx method, supply the fully qualified path of the Visio document, and include the arguments you want to use—in this case, Docked and Read-only.
string docPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments) + @"\test\MyDrawing.vsd"; this.Application.Documents.OpenEx(docPath, ((short)Microsoft.Office.Interop.Visio.VisOpenSaveArgs.visOpenDocked + (short)Microsoft.Office.Interop.Visio.VisOpenSaveArgs.visOpenRO));
Compiling the Code
This code example requires the following:
A Visio document named myDrawing.vsd must be located in a directory named Test in the My Documents folder (for Windows XP and earlier) or the Documents folder (for Windows Vista).