473,327 Members | 2,094 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Dynamically generate Visio from .Net

I would like to dynamically create a Visio diagram from .Net. I tried
looking at the Visio SDK, but the samples are extremely convoluted for me to
understand.

Does someone have an example of creating a basic drawing with two shapes
connected? I can then expand that example to include other elements.

Also, my plan is for this project to be an ASP.Net website. Is Visio
required to be on the web server in order to generate the Visio documents?
If so, a full install, or just the .Net option in the Visio install options.
--
Mike Logan
Sep 12 '06 #1
4 17376
Hi Mike,

First of all, I would like to confirm my understanding of your issue.
From your description, I understand that you wants to dynamically generate
Visio document at ASP.NET Server side.
Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.

Firstly to utilize the Visio function, we do need the Visio application
installed and automation the Visio application to do the job we do
manually. This is called Automation.
But Server side Automation of Office products is not support which have
many underlying problem.
257757 Considerations for server-side Automation of Office
http://support.microsoft.com/default...b;EN-US;257757

If we want to generate Visio document programming,, we should use client
side automation, e.g. a Winform application.
Here is a link for your reference.
305199 How to automate Visio with Visual Basic .NET
http://support.microsoft.com/default...b;EN-US;305199

Actually we can use the Macro recording function to track the code used to
do some manually job programming.
e.g.
1. Open a Visio application and new a Drawing
2. Press Tools/Macro/Record New Macro
3. And then we can do our job manually
e.g. drop two shape and a connector onto the drawing and connect them
4. Stop Macro recording
5. Press Atl+F11 to view the macro recorded.
Here is what I got.
Sub Macro1()
Application.Windows.ItemEx("Drawing1").Activate
Application.ActiveWindow.Page.Drop
Application.Documents.Item("BASFLO_M.VSS").Masters .ItemU("Process"),
3.838583, 9.84252
Application.Windows.ItemEx("Drawing1").Activate
Application.ActiveWindow.Page.Drop
Application.Documents.Item("BASFLO_M.VSS").Masters .ItemU("Process"),
3.838583, 7.775591
Application.Windows.ItemEx("Drawing1").Activate
Application.ActiveWindow.Page.Drop
Application.Documents.Item("BASFLO_M.VSS").Masters .ItemU("Dynamic
connector"), 2.165354, 8.858268
Dim UndoScopeID1 As Long
UndoScopeID1 = Application.BeginUndoScope("Size Object")
Dim vsoCell1 As Visio.Cell
Dim vsoCell2 As Visio.Cell
Set vsoCell1 =
Application.ActiveWindow.Page.Shapes.ItemFromID(3) .CellsU("EndX")
Set vsoCell2 =
Application.ActiveWindow.Page.Shapes.ItemFromID(2) .CellsSRC(7, 3, 0)
vsoCell1.GlueTo vsoCell2
Application.EndUndoScope UndoScopeID1, True

Dim UndoScopeID2 As Long
UndoScopeID2 = Application.BeginUndoScope("Size Object")
Dim vsoCell3 As Visio.Cell
Dim vsoCell4 As Visio.Cell
Set vsoCell3 =
Application.ActiveWindow.Page.Shapes.ItemFromID(3) .CellsU("BeginX")
Set vsoCell4 =
Application.ActiveWindow.Page.Shapes.ItemFromID(1) .CellsSRC(7, 2, 0)
vsoCell3.GlueTo vsoCell4
Application.EndUndoScope UndoScopeID2, True

End Sub

We can easy convert the code to VB.NET, because in nature we are
programming against the Visio Object Modal.
In the SDK, it also involved the Save As Web Page API, which is also the
automation behavior which is to do the Save As Web Page menu command
programming.

In a summary, this solution is not proper to run at ASP.NET server side due
to the KB above.

Also ASP.NET can use .NET buildin funtion to create bitmap on the fly and
show to the client. So if your scenario is not complex, maybe this is an
alternative.
Create Snazzy Web Charts and Graphics On the Fly with the .NET Framework
http://msdn.microsoft.com/msdnmag/issues/02/02/ASPDraw/

If you have any concern, please feel free to let me know.

Best regards,

Peter Huang

Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Sep 13 '06 #2
Thank you Peter for the detailed response. I notice than you can create XML
Visio documents (.VDX) files. Do you suppose a better solution that would
not include server side automation of is to generate the XML file. I have
downloaded the Office Reference XML schemas.

Thanks again for the reply.
--
Mike Logan
""Peter Huang" [MSFT]" wrote:
Hi Mike,

First of all, I would like to confirm my understanding of your issue.
From your description, I understand that you wants to dynamically generate
Visio document at ASP.NET Server side.
Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.

Firstly to utilize the Visio function, we do need the Visio application
installed and automation the Visio application to do the job we do
manually. This is called Automation.
But Server side Automation of Office products is not support which have
many underlying problem.
257757 Considerations for server-side Automation of Office
http://support.microsoft.com/default...b;EN-US;257757

If we want to generate Visio document programming,, we should use client
side automation, e.g. a Winform application.
Here is a link for your reference.
305199 How to automate Visio with Visual Basic .NET
http://support.microsoft.com/default...b;EN-US;305199

Actually we can use the Macro recording function to track the code used to
do some manually job programming.
e.g.
1. Open a Visio application and new a Drawing
2. Press Tools/Macro/Record New Macro
3. And then we can do our job manually
e.g. drop two shape and a connector onto the drawing and connect them
4. Stop Macro recording
5. Press Atl+F11 to view the macro recorded.
Here is what I got.
Sub Macro1()
Application.Windows.ItemEx("Drawing1").Activate
Application.ActiveWindow.Page.Drop
Application.Documents.Item("BASFLO_M.VSS").Masters .ItemU("Process"),
3.838583, 9.84252
Application.Windows.ItemEx("Drawing1").Activate
Application.ActiveWindow.Page.Drop
Application.Documents.Item("BASFLO_M.VSS").Masters .ItemU("Process"),
3.838583, 7.775591
Application.Windows.ItemEx("Drawing1").Activate
Application.ActiveWindow.Page.Drop
Application.Documents.Item("BASFLO_M.VSS").Masters .ItemU("Dynamic
connector"), 2.165354, 8.858268
Dim UndoScopeID1 As Long
UndoScopeID1 = Application.BeginUndoScope("Size Object")
Dim vsoCell1 As Visio.Cell
Dim vsoCell2 As Visio.Cell
Set vsoCell1 =
Application.ActiveWindow.Page.Shapes.ItemFromID(3) .CellsU("EndX")
Set vsoCell2 =
Application.ActiveWindow.Page.Shapes.ItemFromID(2) .CellsSRC(7, 3, 0)
vsoCell1.GlueTo vsoCell2
Application.EndUndoScope UndoScopeID1, True

Dim UndoScopeID2 As Long
UndoScopeID2 = Application.BeginUndoScope("Size Object")
Dim vsoCell3 As Visio.Cell
Dim vsoCell4 As Visio.Cell
Set vsoCell3 =
Application.ActiveWindow.Page.Shapes.ItemFromID(3) .CellsU("BeginX")
Set vsoCell4 =
Application.ActiveWindow.Page.Shapes.ItemFromID(1) .CellsSRC(7, 2, 0)
vsoCell3.GlueTo vsoCell4
Application.EndUndoScope UndoScopeID2, True

End Sub

We can easy convert the code to VB.NET, because in nature we are
programming against the Visio Object Modal.
In the SDK, it also involved the Save As Web Page API, which is also the
automation behavior which is to do the Save As Web Page menu command
programming.

In a summary, this solution is not proper to run at ASP.NET server side due
to the KB above.

Also ASP.NET can use .NET buildin funtion to create bitmap on the fly and
show to the client. So if your scenario is not complex, maybe this is an
alternative.
Create Snazzy Web Charts and Graphics On the Fly with the .NET Framework
http://msdn.microsoft.com/msdnmag/issues/02/02/ASPDraw/

If you have any concern, please feel free to let me know.

Best regards,

Peter Huang

Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Sep 13 '06 #3
Hi Mike,

Yes the Create the XML file vdx may be an alternative.
We have open XML format schema for Office 2003.
But if we save a simple visio drawing with two connected shape as vdx, we
will find that it is not trivial.
Because so far in the Visio SDK, we did not have an API to programming
Visio related XML document(e.g. an AddShape method will add a shape to an
existing Visio XML Document, there is no such one), it is difficult to
program a practical solution.

If we go through the solution, we have to leverate the .NET XML library to
create a XML file confined to the Visio XML file schema.
If we create a simple Visio drawing and save as vdx file and then open it
in notepad, we will find that it is hard to create such a file with XML
format even if it is a very simple drawing.

If you have any other concern, please feel free to let me know.
Best regards,

Peter Huang

Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Sep 14 '06 #4
Hi Mike,

I am posting to check how the thing is going on.

If you have any concern on this issue, please feel free to let me know

Best regards,

Peter Huang

Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Sep 18 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Stefan Svensson | last post by:
I posted this request for help in Visio, troubleshooting newsgroup and Installation newsgroup, about 1,5 months ago but without result. "I recently installed Visio .NET Enterprise Architect 2003...
3
by: Roman S. Golubin1709176985 | last post by:
All how do you do! Who what cases uses for C# programming? I have an experience with Microsoft Visio several days. He has a problem with interface inheritance... óan who that other advise? ...
1
by: Arjen | last post by:
Hello, With XDE (xml file) and Visio (uml) you can generate C# classes code from diagrams. Now I have made some C# classes with Visio UML diagrams. Inside these classes I have some variables...
1
by: Davey | last post by:
I have Visio for Visual Studio.NET Enterprise Architect 2003 and I am designing a PostgresSQL database using it. Is it possible to generate and manage a PostgresSQL database using Visio?
2
by: Dominic | last post by:
I try to use Visio filter but it needs to install by using installation package from Microsoft. If I need to use only DLL for extract text from vsd with my application, how can I do? I need...
1
by: =?Utf-8?B?SkFXQUFIQVI=?= | last post by:
i just wanted to hide visio stencil blocks from my parent form. in child form i used thie following code to hide....
14
by: joemo2003 | last post by:
I created a button in excel sheet, and that button need to browse and open a visio drawing. I try two ways to do it, but either way work. can anyone help? First way: Private Sub...
5
by: cmk128 | last post by:
Hi I need to create a website, the function of the web should near microsoft visio. Please tell me what php library can let me to create a sharp on the web, and able to drag it and put a line to...
0
by: frederick.the.fool | last post by:
I'm writing a project that does Visio automation. I'm writing it in C+ +/CLI because it needs to reference a good amount of native C++ code. One way to call the Visio API, of course, is to use...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.