Visio

Local

External


(Programming) Goto Page


private void gotoPage( int page)
{
	if ( m_visioApp.ActiveDocument.Pages.Count >= page) 
	{
		System.Array names;
		m_visioApp.ActiveDocument.Pages.GetNames( out names);

		int num =  names.GetLowerBound(0) + page;
		Visio.Page objPage = m_visioApp.ActiveDocument.Pages.get_ItemU( names.GetValue(num));
		axDrawingControl1.Window.Page = objPage;
	}
}

Programming

Useful snippets http://www.mvps.org/visio/VBA.htm

Docs (local) C:\Program Files\Microsoft Office\Visio11\SDK\Docs

Forum http://www.visimation.com/forums/forum.asp

To embed a Viso diagram into a Frame

  1. Show the toolbox in Visual Studio
  2. Right click and choose customize toolbox
  3. Add the COM object Microsoft Visio Drawing Control
  4. Place the Drawing Control on your Frame

Getting the application from an embedded Control

  1. axDrawingControl1.Window.Application

Enumerating pages and setting which is active


				int x = 0;
				foreach ( Visio.Page page in axDrawingControl1.Document.Pages) 
				{
					x++;
					if ( x == 1) 
					{
						axDrawingControl1.Window.Page = page;
					}
				}

private void showShapes()
{
	foreach( Visio.Page objPage in m_visioApp.ActiveDocument.Pages) 
	{
		foreach( Visio.Shape objShape in objPage.Shapes)
		{
			DebugPrintln( "Shape '" + objShape.NameU);
		}
		// How do shapes ever get into a layer?
		foreach( Visio.Layer objLayer in objPage.Layers) 
		{
			foreach( Visio.Shape objShape in objLayer.Page.Shapes) 
			{
				DebugPrintln( "Shape '" + objLayer.NameU + " -> " + objShape.NameU);
			}
		}
	}
}




Gotchas

"Requested Operation Is Presently Disabled" when something other program is using Visio 2003

Info about it at Microsoft http://support.microsoft.com/default.aspx?scid=kb;EN-US;831070

WORKAROUND: To work around this problem, use the SetFocus method to make your Visio Drawing Control active before the DoCmd method in your VBA macro.


Basic Info

OperationHow to do it
Background sheet, changing its sizeChange the Page Size: File | Page Setup | Page Size | Custom Size