visio 2013 how to enumerate all objects and retrieve textbox value

Hi

I have a Visio 2013 diagram with networking objects.

Each object has a text value.

How do I go to each object and retrieve its text value?

I prefer using C# but any language i.e. VB/VBA is fine.

T

March 14th, 2014 6:24pm

The easiest way is a simple vba macro that walks the pages and the shapes on the pages.

there are several examples of this over on Chris Roth's site. www.visguy.com

al

Free Windows Admin Tool Kit Click here and download it now
March 15th, 2014 3:09am

You can use the following c# code for this. Use the visio.

Please let me know if this solved your issue

Application visApp = new Visio.Application(); visApp.Visible = true;
            Document document = visApp.Documents.Open(@"C:\xyz.vsdx");
            foreach (Page page in document.Pages)
            {
                foreach (Shape shape in page.Shapes)
                    Console.WriteLine(shape.Text);
            }

March 18th, 2014 5:25pm

You can use the following c# code for this. Use the visio.

Please let me know if this solved your issue

Application visApp = new Visio.Application(); visApp.Visible = true;
            Document document = visApp.Documents.Open(@"C:\xyz.vsdx");
            foreach (Page page in document.Pages)
            {
                foreach (Shape shape in page.Shapes)
                    Console.WriteLine(shape.Text);
            }

Free Windows Admin Tool Kit Click here and download it now
March 18th, 2014 5:25pm

You can use the following c# code for this. Use the visio.

Please let me know if this solved your issue

Application visApp = new Visio.Application(); visApp.Visible = true;
            Document document = visApp.Documents.Open(@"C:\xyz.vsdx");
            foreach (Page page in document.Pages)
            {
                foreach (Shape shape in page.Shapes)
                    Console.WriteLine(shape.Text);
            }

March 18th, 2014 5:25pm

You can use the following c# code for this. Use the visio.

Please let me know if this solved your issue

Application visApp = new Visio.Application(); visApp.Visible = true;
            Document document = visApp.Documents.Open(@"C:\xyz.vsdx");
            foreach (Page page in document.Pages)
            {
                foreach (Shape shape in page.Shapes)
                    Console.WriteLine(shape.Text);
            }

Free Windows Admin Tool Kit Click here and download it now
March 18th, 2014 5:25pm

You can use the following c# code for this. Use the visio.

Please let me know if this solved your issue

Application visApp = new Visio.Application(); visApp.Visible = true;
            Document document = visApp.Documents.Open(@"C:\xyz.vsdx");
            foreach (Page page in document.Pages)
            {
                foreach (Shape shape in page.Shapes)
                    Console.WriteLine(shape.Text);
            }

March 18th, 2014 5:25pm

You can use the following c# code for this. Use the visio.

Please let me know if this solved your issue

Application visApp = new Visio.Application(); visApp.Visible = true;
            Document document = visApp.Documents.Open(@"C:\xyz.vsdx");
            foreach (Page page in document.Pages)
            {
                foreach (Shape shape in page.Shapes)
                    Console.WriteLine(shape.Text);
            }

Free Windows Admin Tool Kit Click here and download it now
March 18th, 2014 5:25pm

You can use the following c# code for this. Use the visio.

Please let me know if this solved your issue

Application visApp = new Visio.Application(); visApp.Visible = true;
            Document document = visApp.Documents.Open(@"C:\xyz.vsdx");
            foreach (Page page in document.Pages)
            {
                foreach (Shape shape in page.Shapes)
                    Console.WriteLine(shape.Text);
            }

March 18th, 2014 5:25pm

You can use the following c# code for this. Use the visio.

Please let me know if this solved your issue

Application visApp = new Visio.Application(); visApp.Visible = true;
            Document document = visApp.Documents.Open(@"C:\xyz.vsdx");
            foreach (Page page in document.Pages)
            {
                foreach (Shape shape in page.Shapes)
                    Console.WriteLine(shape.Text);
            }

Free Windows Admin Tool Kit Click here and download it now
March 18th, 2014 5:25pm

You can use the following c# code for this. Use the visio.

Please let me know if this solved your issue

Application visApp = new Visio.Application(); visApp.Visible = true;
            Document document = visApp.Documents.Open(@"C:\xyz.vsdx");
            foreach (Page page in document.Pages)
            {
                foreach (Shape shape in page.Shapes)
                    Console.WriteLine(shape.Text);
            }

March 18th, 2014 5:25pm

You can use the following c# code for this. Use the visio.

Please let me know if this solved your issue

Application visApp = new Visio.Application(); visApp.Visible = true;
            Document document = visApp.Documents.Open(@"C:\xyz.vsdx");
            foreach (Page page in document.Pages)
            {
                foreach (Shape shape in page.Shapes)
                    Console.WriteLine(shape.Text);
            }

Free Windows Admin Tool Kit Click here and download it now
March 18th, 2014 5:25pm

You can use the following c# code for this. Use the visio.

Please let me know if this solved your issue

Application visApp = new Visio.Application(); visApp.Visible = true;
            Document document = visApp.Documents.Open(@"C:\xyz.vsdx");
            foreach (Page page in document.Pages)
            {
                foreach (Shape shape in page.Shapes)
                    Console.WriteLine(shape.Text);
            }

March 18th, 2014 5:25pm

You can use the following c# code for this. Use the visio.

Please let me know if this solved your issue

Application visApp = new Visio.Application(); visApp.Visible = true;
            Document document = visApp.Documents.Open(@"C:\xyz.vsdx");
            foreach (Page page in document.Pages)
            {
                foreach (Shape shape in page.Shapes)
                    Console.WriteLine(shape.Text);
            }

Free Windows Admin Tool Kit Click here and download it now
March 18th, 2014 5:25pm

You can use the following c# code for this. Use the visio.

Please let me know if this solved your issue

Application visApp = new Visio.Application(); visApp.Visible = true;
            Document document = visApp.Documents.Open(@"C:\xyz.vsdx");
            foreach (Page page in document.Pages)
            {
                foreach (Shape shape in page.Shapes)
                    Console.WriteLine(shape.Text);
            }

March 18th, 2014 5:25pm

You can use the following c# code for this. Use the visio.

Please let me know if this solved your issue

Application visApp = new Visio.Application(); visApp.Visible = true;
            Document document = visApp.Documents.Open(@"C:\xyz.vsdx");
            foreach (Page page in document.Pages)
            {
                foreach (Shape shape in page.Shapes)
                    Console.WriteLine(shape.Text);
            }

Free Windows Admin Tool Kit Click here and download it now
March 18th, 2014 5:25pm

You can use the following c# code for this. Use the visio.

Please let me know if this solved your issue

Application visApp = new Visio.Application(); visApp.Visible = true;
            Document document = visApp.Documents.Open(@"C:\xyz.vsdx");
            foreach (Page page in document.Pages)
            {
                foreach (Shape shape in page.Shapes)
                    Console.WriteLine(shape.Text);
            }

March 18th, 2014 5:25pm

You can use the following c# code for this. Use the visio.

Please let me know if this solved your issue

Application visApp = new Visio.Application(); visApp.Visible = true;
            Document document = visApp.Documents.Open(@"C:\xyz.vsdx");
            foreach (Page page in document.Pages)
            {
                foreach (Shape shape in page.Shapes)
                    Console.WriteLine(shape.Text);
            }

Free Windows Admin Tool Kit Click here and download it now
March 18th, 2014 5:25pm

You can use the following c# code for this. Use the visio.

Please let me know if this solved your issue

Application visApp = new Visio.Application(); visApp.Visible = true;
            Document document = visApp.Documents.Open(@"C:\xyz.vsdx");
            foreach (Page page in document.Pages)
            {
                foreach (Shape shape in page.Shapes)
                    Console.WriteLine(shape.Text);
            }

March 18th, 2014 5:25pm

You can use the following c# code for this. Use the visio.

Please let me know if this solved your issue

Application visApp = new Visio.Application(); visApp.Visible = true;
            Document document = visApp.Documents.Open(@"C:\xyz.vsdx");
            foreach (Page page in document.Pages)
            {
                foreach (Shape shape in page.Shapes)
                    Console.WriteLine(shape.Text);
            }

Free Windows Admin Tool Kit Click here and download it now
March 18th, 2014 5:25pm

You can use the following c# code for this. Use the visio.

Please let me know if this solved your issue

Application visApp = new Visio.Application(); visApp.Visible = true;
            Document document = visApp.Documents.Open(@"C:\xyz.vsdx");
            foreach (Page page in document.Pages)
            {
                foreach (Shape shape in page.Shapes)
                    Console.WriteLine(shape.Text);
            }

March 18th, 2014 5:25pm

Hi

Do I use :

using Microsoft.Office.Interop.Visio;

If so, which reference do I use?

Thanks.

- Andre

Free Windows Admin Tool Kit Click here and download it now
September 30th, 2014 12:55am

When you use the Visual Studio and start a office/sharepoint project for Visio 2013 the correct references are added automatically.

October 2nd, 2014 12:26pm

Hi

How do I go about setting this up for execution?

- Andre

Free Windows Admin Tool Kit Click here and download it now
March 13th, 2015 2:50pm

Still haven't gotten anywhere with this.

The MSDN site only has how to open a document which I can easily do.

Enumeration is a different matter.

March 31st, 2015 2:16pm

There's loads of info on how to do this on the VisioGuy site, and in the Visio SDK, and on MSDN, and you've been given C# code to do your getting text.

P.S. You need to iterate all the shapes, not enumerate.

Free Windows Admin Tool Kit Click here and download it now
March 31st, 2015 2:52pm

Hi Paul

Thanks so much!

Clarifying that I need to Iterate instead of enumerate helped.

I then found this gem:

https://msdn.microsoft.com/en-us/library/office/ff767988.aspx?f=255&MSPPError=-2147217396

This is what I needed to get the app going.

Swetha, thanks for the C# code but I am not sure where to put this in the Visio since I only see VBA based Macros in the Visio document :-(

April 1st, 2015 9:06am

Swetha

Thanks for the C# code but I am not sure where to put this in the Visio since I only see VBA based Macros in the document :-(

Free Windows Admin Tool Kit Click here and download it now
April 1st, 2015 9:07am

You don't put C# code in Visio, you use C# to build an addon for Visio with Visual Studio. I think for what you want you need to use VBA, i.e. a macro.

P.S. you will not make any friends here by unmarking all the answers you've been given and then marking your own comment as the answer (when it's not).

April 1st, 2015 9:15am

Hi Paul

Thanks...and so sorry to you and the team.

- Andre

Free Windows Admin Tool Kit Click here and download it now
April 1st, 2015 9:18am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics