COM Exception In Visio 2007

A

Asif

Hi all,

I am using Visio 2007 activeX control in our application using VB.net.
I am using Visio Application Class DoCmd Command to open different
Visio Dialog Forms like Text, Line Fill, and Spelling etc.

There are two issues in using DoCmd Command:

1- Once I click Cancel button of any Dialog Form (Text, Line Fill etc)
System.Runtime.InteropServices.COMException is thrown with the
following details.

ex.Message: "Cancel."
ex.TargetSite
{System.Reflection.RuntimeMethodInfo}
[System.Reflection.RuntimeMethodInfo]:
{System.Reflection.RuntimeMethodInfo}
Attributes: 454
CallingConvention: 33
DeclaringType: {System.RuntimeType}
IsAbstract: False
IsAssembly: False
IsConstructor: False
IsFamily: False
IsFamilyAndAssembly: False
IsFamilyOrAssembly: False
IsFinal: False
IsHideBySig: True
IsPrivate: False
IsPublic: True
IsSpecialName: False
IsStatic: False
IsVirtual: True
MemberType: Method
MethodHandle: {System.RuntimeMethodHandle}
Name: "DoCmd"
ReflectedType: {System.RuntimeType}

2- If I try to open Format Style Dialog Form (VisioApp.DoCmd
(VisUICmds.visCmdFormatStyle)
System.Runtime.InteropServices.COMException is also thrown but with a
little bit different information

ex.Message:"Requested operation is presently disabled."
ex.TargetSite
{System.Reflection.RuntimeMethodInfo}
[System.Reflection.RuntimeMethodInfo]:
{System.Reflection.RuntimeMethodInfo}
Attributes: 454
CallingConvention: 33
DeclaringType: {System.RuntimeType}
IsAbstract: False
IsAssembly: False
IsConstructor: False
IsFamily: False
IsFamilyAndAssembly: False
IsFamilyOrAssembly: False
IsFinal: False
IsHideBySig: True
IsPrivate: False
IsPublic: True
IsSpecialName: False
IsStatic: False
IsVirtual: True
MemberType: Method
MethodHandle: {System.RuntimeMethodHandle}
Name: "DoCmd"
ReflectedType: {System.RuntimeType}

Can anyone tell me about why it is happening and any workaround for
it?

Thanks

Asif
 
J

JuneTheSecond

All dialogs of Visio return error message, when you press cancel button.
Please put On Error Resume Next in front of docmd line.
 
A

Asif

Hello Asif

Have you tried using the IOleCommandTarget COM interface rather than DoCmd?
When using the Visio 2003 Drawing Control I encountered errors when using
DoCmd for operations like spell check.

For details on using IOleCommandTarget with the Visio Drawing Control seehttp://msdn2.microsoft.com/en-us/library/aa192480(office.11).aspx#off...

Best regards
Roger Billsdon



Asif said:
I am using Visio 2007 activeX control in our application using VB.net.
I am using Visio Application Class DoCmd Command to open different
Visio Dialog Forms like Text, Line Fill, and Spelling etc.
There are two issues in using DoCmd Command:
1- Once I click Cancel button of any Dialog Form (Text, Line Fill etc)
System.Runtime.InteropServices.COMException is thrown with the
following details.
ex.Message: "Cancel."
ex.TargetSite
{System.Reflection.RuntimeMethodInfo}
[System.Reflection.RuntimeMethodInfo]:
{System.Reflection.RuntimeMethodInfo}
Attributes: 454
CallingConvention: 33
DeclaringType: {System.RuntimeType}
IsAbstract: False
IsAssembly: False
IsConstructor: False
IsFamily: False
IsFamilyAndAssembly: False
IsFamilyOrAssembly: False
IsFinal: False
IsHideBySig: True
IsPrivate: False
IsPublic: True
IsSpecialName: False
IsStatic: False
IsVirtual: True
MemberType: Method
MethodHandle: {System.RuntimeMethodHandle}
Name: "DoCmd"
ReflectedType: {System.RuntimeType}
2- If I try to open Format Style Dialog Form (VisioApp.DoCmd
(VisUICmds.visCmdFormatStyle)
System.Runtime.InteropServices.COMException is also thrown but with a
little bit different information
ex.Message:"Requested operation is presently disabled."
ex.TargetSite
{System.Reflection.RuntimeMethodInfo}
[System.Reflection.RuntimeMethodInfo]:
{System.Reflection.RuntimeMethodInfo}
Attributes: 454
CallingConvention: 33
DeclaringType: {System.RuntimeType}
IsAbstract: False
IsAssembly: False
IsConstructor: False
IsFamily: False
IsFamilyAndAssembly: False
IsFamilyOrAssembly: False
IsFinal: False
IsHideBySig: True
IsPrivate: False
IsPublic: True
IsSpecialName: False
IsStatic: False
IsVirtual: True
MemberType: Method
MethodHandle: {System.RuntimeMethodHandle}
Name: "DoCmd"
ReflectedType: {System.RuntimeType}
Can anyone tell me about why it is happening and any workaround for
it?

Asif- Hide quoted text -

- Show quoted text -

Thanks Billsdon, I did use the IOleCommandTarget COM interface
mentioned in given link which works well, but there are two issues
that are:

1- Some commands did not launch any Dialog Form like (Format Style)
this.SendCommand(Microsoft.Office.Interop.Visio.VisUICmds.visCmdFormatStyle)

2-Call spell check command (visCmdToolsSpelling) launches the Spell
check Dialog Form but clicking on "OK" button on form that contains
the text "The spelling check is completed" , the mouse pointer
converts to "Hour Glass" and does not go away until you hit "ESC" key.

One more thing is that I am using Visio 2007 Drawing Control so there
is some thing more to fix the issue?

Thanks

Asif
 
R

Roger

Hello Asif

Maybe JuneTheSecond's "ToolButton made with OleCommandTarget for VB.Net"
sample code will help. SendKeys is another fallback alternative that is worth
trying, eg for spell checking try:
VisioDrawingControl.Focus()
SendKeys.SendWait("{F7}")

Best regards
Roger

Asif said:
Hello Asif

Have you tried using the IOleCommandTarget COM interface rather than DoCmd?
When using the Visio 2003 Drawing Control I encountered errors when using
DoCmd for operations like spell check.

For details on using IOleCommandTarget with the Visio Drawing Control seehttp://msdn2.microsoft.com/en-us/library/aa192480(office.11).aspx#off...

Best regards
Roger Billsdon



Asif said:
I am using Visio 2007 activeX control in our application using VB.net.
I am using Visio Application Class DoCmd Command to open different
Visio Dialog Forms like Text, Line Fill, and Spelling etc.
There are two issues in using DoCmd Command:
1- Once I click Cancel button of any Dialog Form (Text, Line Fill etc)
System.Runtime.InteropServices.COMException is thrown with the
following details.
ex.Message: "Cancel."
ex.TargetSite
{System.Reflection.RuntimeMethodInfo}
[System.Reflection.RuntimeMethodInfo]:
{System.Reflection.RuntimeMethodInfo}
Attributes: 454
CallingConvention: 33
DeclaringType: {System.RuntimeType}
IsAbstract: False
IsAssembly: False
IsConstructor: False
IsFamily: False
IsFamilyAndAssembly: False
IsFamilyOrAssembly: False
IsFinal: False
IsHideBySig: True
IsPrivate: False
IsPublic: True
IsSpecialName: False
IsStatic: False
IsVirtual: True
MemberType: Method
MethodHandle: {System.RuntimeMethodHandle}
Name: "DoCmd"
ReflectedType: {System.RuntimeType}
2- If I try to open Format Style Dialog Form (VisioApp.DoCmd
(VisUICmds.visCmdFormatStyle)
System.Runtime.InteropServices.COMException is also thrown but with a
little bit different information
ex.Message:"Requested operation is presently disabled."
ex.TargetSite
{System.Reflection.RuntimeMethodInfo}
[System.Reflection.RuntimeMethodInfo]:
{System.Reflection.RuntimeMethodInfo}
Attributes: 454
CallingConvention: 33
DeclaringType: {System.RuntimeType}
IsAbstract: False
IsAssembly: False
IsConstructor: False
IsFamily: False
IsFamilyAndAssembly: False
IsFamilyOrAssembly: False
IsFinal: False
IsHideBySig: True
IsPrivate: False
IsPublic: True
IsSpecialName: False
IsStatic: False
IsVirtual: True
MemberType: Method
MethodHandle: {System.RuntimeMethodHandle}
Name: "DoCmd"
ReflectedType: {System.RuntimeType}
Can anyone tell me about why it is happening and any workaround for
it?

Asif- Hide quoted text -

- Show quoted text -

Thanks Billsdon, I did use the IOleCommandTarget COM interface
mentioned in given link which works well, but there are two issues
that are:

1- Some commands did not launch any Dialog Form like (Format Style)
this.SendCommand(Microsoft.Office.Interop.Visio.VisUICmds.visCmdFormatStyle)

2-Call spell check command (visCmdToolsSpelling) launches the Spell
check Dialog Form but clicking on "OK" button on form that contains
the text "The spelling check is completed" , the mouse pointer
converts to "Hour Glass" and does not go away until you hit "ESC" key.

One more thing is that I am using Visio 2007 Drawing Control so there
is some thing more to fix the issue?

Thanks

Asif
 
Top