DrawingResizeType - how to set value in C#

Started by cnayan, August 13, 2013, 12:14:09 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

cnayan

Hi,

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

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

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

canvas is

    AxMicrosoft.Office.Interop.VisOcx.AxDrawingControl canvas;

Before setting value 1, it looks like VSD1. After, VSD2.

aledlund

I'd suggest you check out 'paperkind' in the page sheet,
al

cnayan

Okay, I used the macro recorder and found this is the 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


    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
----------------------------------------
System.Windows.Forms
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5468 (Win7SP1GDR.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5467 (Win7SP1GDR.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5467 (Win7SP1GDR.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
Microsoft.Office.Interop.Visio
    Assembly Version: 14.0.0.0
    Win32 Version: 14.0.4756.1000
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.Office.Interop.Visio/14.0.0.0__71e9bce111e9429c/Microsoft.Office.Interop.Visio.dll
----------------------------------------
AxInterop.Visocx
    Assembly Version: 12.0.0.0
    Win32 Version: 12.0.0.0
    CodeBase: file:///C:/Windows/assembly/GAC/AxInterop.Visocx/12.0.0.0__d2d1064e7cd0412f/AxInterop.Visocx.dll
----------------------------------------
System.Configuration
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5473 (Win7SP1GDR.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5473 (Win7SP1GDR.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
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

cnayan

Quote from: aledlund on August 13, 2013, 02:03:39 PM
I'd suggest you check out 'paperkind' in the page sheet,
al

PaperKind = 1
It remains same for Visio and C# app. But Visio doesn't observe the exception.

cnayan

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

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