Embedding Visio in ASP.NET, HTML, ASP or PHP
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
Visio 2010.
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.
Download Office Viewer Component and View Sample Projects
Office Viewer Component Online Demo
Figure 1: Embedding and Displaying Visio in HTML Page.
Create Visio from Component
component method:
VARIANT_BOOL NewVisio([in] BSTR TemplatePath);
Description: Opens a new Visio document object.
Open Visio from Component
Component method:
VARIANT_BOOL OpenVisio([in] BSTR FileName, [in] short Flags);
Description: Opens an existing Visio file using extra information passed in an argument.
Support VBA Programming with Embedded Visio Document
You can use Visual Studio, Javascript, VBScript to programmatically control
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.
docObj.SaveAs "hello.vsd"
MsgBox "Drawing finished!", , "Hello World!"
End Sub
With the OfficeViewerComponent,it's easy to host Visio in a custom solution and extend the function by the office automation.
Embedding MS Word in VB.NET and Automating Word
An Easy Way to Embed Excel in a Web Page
Embedding MS Word Document in HTML
Embed MS Excel in VB 6 and Do the Excel Automation
Disables MS Word Standard Command