When False Means True
I encountered an interesting problem while working with our FirstPoint Office add-in (one of the many joys of working with the Office API!).
In this case, a call to ActiveDocument.CanCheckIn() would return true, even when the value was clearly false. Testing in the VB macro editor in Word would return the correct value consistent and so would invoking the method from the Visual Studio command window.
In Word 2007, this API call seems to work just fine. However, in Word 2003, I had to use reflection to invoke the method to get a proper result:
1 2 3 4 |
<FONT face="'lucida console',monospace"><FONT color=#008000>Type </FONT><FONT color=#000000>type </FONT><FONT color=#5e82fd>= </FONT><FONT color=#000000>_host</FONT><FONT color=#5e82fd>.</FONT><FONT color=#000000>ActiveDocument</FONT><FONT color=#5e82fd>.</FONT><FONT color=#ff8040>GetType</FONT><FONT color=#5e82fd>();</FONT> <FONT color=#008000>MethodInfo </FONT><FONT color=#000000>m </FONT><FONT color=#5e82fd>= </FONT><FONT color=#000000>type</FONT><FONT color=#5e82fd>.</FONT><FONT color=#ff8040>GetMethod</FONT><FONT color=#5e82fd>(</FONT><FONT color=#ff00ff>"CanCheckin"</FONT><FONT color=#5e82fd>);</FONT> <FONT color=#0000ff>object </FONT><FONT color=#000000>result </FONT><FONT color=#5e82fd>= </FONT><FONT color=#000000>m</FONT><FONT color=#5e82fd>.</FONT><FONT color=#ff8040>Invoke</FONT><FONT color=#5e82fd>(</FONT><FONT color=#000000>_host</FONT><FONT color=#5e82fd>.</FONT><FONT color=#000000>ActiveDocument</FONT><FONT color=#5e82fd>, </FONT><FONT color=#0000ff>null</FONT><FONT color=#5e82fd>);</FONT> <FONT color=#000000>canCheckInDocument </FONT><FONT color=#5e82fd>= </FONT><FONT color=#008000>Convert</FONT><FONT color=#5e82fd>.</FONT><FONT color=#ff8040>ToBoolean</FONT><FONT color=#5e82fd>(</FONT><FONT color=#000000>result</FONT><FONT color=#5e82fd>);</FONT></FONT> |