【问题标题】:How to change value of "DrawingResizeType"如何更改“DrawingResizeType”的值
【发布时间】:2013-08-13 12:24:08
【问题描述】:

此代码不起作用 - 页面大小不会改变:

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

画布是

AxMicrosoft.Office.Interop.VisOcx.AxDrawingControl canvas;

谁能说出哪里出了问题以及如何纠正?

图像 VSD1 显示了原始图表。将值更改为 1 后,它应该看起来像 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:line 121 中的 VisioDemo.Form1.btnReConnect_Click(Object sender, EventArgs ea) 在 System.Windows.Forms.Control.OnClick(EventArgs e) 在 System.Windows.Forms.Button.OnClick(EventArgs e) 在 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs 事件) 在 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(消息& m) 在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(消息和 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)

代码库:file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll

VisioDemo 程序集版本:1.0.0.0 Win32版本:1.0.0.0

代码库:file:///C:/bin/x86/Debug/VisioDemo.exe

Microsoft.Office.Interop.VisOcx 程序集版本:14.0.0.0 Win32版本:14.0.4756.1000 代码库:file:///C:/Windows/assembly/GAC_MSIL/Microsoft.Office.Interop.VisOcx/14.0.0.0__71e9bce111e9429c/Microsoft.Office.Interop.VisOcx.dll

【问题讨论】:

    标签: c# visio visio-2010


    【解决方案1】:

    微软承认这个问题是真正的 Visio 问题并发布了一个补丁

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-02-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-23
      相关资源
      最近更新 更多