如何更改“DrawingResizeType”的值

时间:2013-08-13 12:24:08

标签: c# visio visio-2010

此代码无效 - 页面大小不会更改:

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

画布是

AxMicrosoft.Office.Interop.VisOcx.AxDrawingControl canvas;

任何人都能说出错误以及如何纠正错误吗?

图像VSD1显示原始图表。将值更改为1后,它应该看起来像VSD2。

VSD1 VSD2

更新

好的,我使用了宏录制器,发现这是VB代码

[VB代码]

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

我在C#中尝试了相同的操作,但它抛出了COM异常

[C#代码]

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

异常详情 System.Runtime.InteropServices.COMException(0x86DB0C89):

发生了异常。    在Microsoft.Office.Interop.Visio.IVPage.AutoSizeDrawing()    在C:\ Form1.cs中的VisioDemo.Form1.btnReConnect_Click(Object sender,EventArgs ea):第121行    在System.Windows.Forms.Control.OnClick(EventArgs e)    在System.Windows.Forms.Button.OnClick(EventArgs e)    在System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)    在System.Windows.Forms.Control.WmMouseUp(消息& m,MouseButtons按钮,Int32点击)    在System.Windows.Forms.Control.WndProc(消息& m)    在System.Windows.Forms.ButtonBase.WndProc(消息& m)    在System.Windows.Forms.Button.WndProc(消息& m)    在System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)    在System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)    在System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd,Int32 msg,IntPtr wparam,IntPtr lparam)

**************已装载的装配************** mscorlib程序     汇编版本:2.0.0.0     Win32版本:2.0.50727.5472(Win7SP1GDR.050727-5400)

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

VisioDemo     汇编版本:1.0.0.0     Win32版本:1.0.0.0

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

Microsoft.Office.Interop.VisOcx     汇编版本:14.0.0.0     Win32版本: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 个答案:

答案 0 :(得分:0)

Microsoft承认此问题为正版Visio问题并发布了补丁

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