How to change value of "DrawingResizeType"

406 views Asked by At

This code is not working - the page size doesn't change:

canvas.Window.Application.ActivePage.PageSheet.get_CellsU("DrawingResizeType").FormulaU = "1";

canvas is

AxMicrosoft.Office.Interop.VisOcx.AxDrawingControl canvas;

Can anyone tell what is wrong and how it can be corrected?

Image VSD1 shows the original diagram. After changing the value to 1, it should look like VSD2.

VSD1 VSD2

Update

Okay, I used the macro recorder and found this is the VB code

[VB code]

ActiveDocument.DiagramServicesEnabled = visServiceVersion140
Application.ActiveWindow.Page.AutoSize = True
Application.ActiveWindow.Page.AutoSizeDrawing

I tried the same in C#, but it throws COM exception

[C# code]

canvas.Window.Application.ActiveDocument.DiagramServicesEnabled = (int)Visio.VisDiagramServices.visServiceVersion140;
Visio.Page p = (Visio.Page)canvas.Window.Application.ActiveWindow.Page;
p.AutoSize = true;
p.AutoSizeDrawing(); //throws COM exception 0x86DB0C89

Exception details System.Runtime.InteropServices.COMException (0x86DB0C89):

An exception occurred. at Microsoft.Office.Interop.Visio.IVPage.AutoSizeDrawing() at VisioDemo.Form1.btnReConnect_Click(Object sender, EventArgs ea) in C:\Form1.cs:line 121 at System.Windows.Forms.Control.OnClick(EventArgs e) at System.Windows.Forms.Button.OnClick(EventArgs e) at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ButtonBase.WndProc(Message& m) at System.Windows.Forms.Button.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

************** Loaded Assemblies ************** mscorlib Assembly Version: 2.0.0.0 Win32 Version: 2.0.50727.5472 (Win7SP1GDR.050727-5400)

CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll

VisioDemo Assembly Version: 1.0.0.0 Win32 Version: 1.0.0.0

CodeBase: file:///C:/bin/x86/Debug/VisioDemo.exe

Microsoft.Office.Interop.VisOcx Assembly Version: 14.0.0.0 Win32 Version: 14.0.4756.1000 CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.Office.Interop.VisOcx/14.0.0.0__71e9bce111e9429c/Microsoft.Office.Interop.VisOcx.dll

1

There are 1 answers

0
Nayan On BEST ANSWER

Microsoft acknowledged this issue as genuine Visio problem and released a patch

http://support.microsoft.com/kb/2878227