Office Viewer Component allows developers to embed Visio in .net based windows forms application or web page. The development language can be ASP, HTML, ASP.NET or PHP,
VB.NET, C#, WPF or JSP.
The component supports seamless embedding with MS Visio 2000, Visio 2003, Visio 2007 and
Edraw Office Viewer Component supports embedding Visio documents in your application by implementing a full featured ActiveX document container. Now you can create, open, edit, view and save Visio documents such as *.vdx, *.vdd in the web page.
Figure 1: Embedding and Displaying Visio in HTML Page.
VARIANT_BOOL NewVisio([in] BSTR TemplatePath);
Description: Opens a new Visio document object.
VARIANT_BOOL OpenVisio([in] BSTR FileName, [in] short Flags);
Description: Opens an existing Visio file using extra information passed in an argument.
Visio. You can read some of the MSDN articles about this Visio SDK topic and try to develop some small sample programs. In
the Visio SDK, you can get some sample program developed in VB 6.0 that opens
Visio document with basic diagram templates with Basic shapes and then add
Rectangle shape to the drawing and then sets the text to "HELLO WORLD".
so The VB code to achieve this task is as follows.
Sub HelloWorld ()
'Instance of Visio
Dim appVisio As Visio.Application
'Documents collection of instance
Dim docsObj As Visio.Documents
'Document to work in
Dim docObj As Visio.Document
'Stencil that contains master
Dim stnObj As Visio.Document
'Master to drop
Dim mastObj As Visio.Master
'Pages collection of document
Dim pagsObj As Visio.Pages
'Page to work in
Dim pagObj As Visio.Page
'Instance of master on page
Dim shpObj As Visio.Shape
'Create an instance of Visio and create a document based on the Basic Diagram template. It doesn't matter if an instance of Visio is already running; the program will run a new one.
Set appVisio = EDOffice.GetApplication
Set docsObj = appVisio.Documents
'Create a document based on the Basic Diagram template that
'automatically opens the Basic Shapes stencil.
Set docObj = docsObj.Add("Basic Diagram.vst")
Set pagsObj = appVisio.ActiveDocument.Pages
'A new document always has at least one page, whose index in the
'Pages collection is 1.
Set pagObj = pagsObj.Item(1)
Set stnObj = appVisio.Documents("Basic Shapes.vss")
Set mastObj = stnObj.Masters("Rectangle")
'Drop the rectangle in the approximate middle of the page.
'Coordinates passed with the Drop method are always inches.
Set shpObj = pagObj.Drop(mastObj, 4.25, 5.5)
'Set the text of the rectangle
shpObj.Text = "Hello World!"
'Save the drawing and quit Visio. The message pauses the program
'so you can see the Visio drawing before the instance closes.
MsgBox "Drawing finished!", , "Hello World!"
With the Office Viewer Component, it's easy to host Visio in a custom solution and extend the function by the office automation.