Results 1 to 5 of 5
  1. #1
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    C# Journey - 2 (2002)

    Notes:

    1. The semicolons are a pain till your brain can remember to tell your finger to type 'em.
    2. You have to fully qualify just about everything when using the Office PIA (Interop Assembly)
    <pre>If you type
    Application.windowstate = wdWindowStateMaximize

    in VBA, the same thing in .Net is
    wordApp.WindowState = Word.WdWindowState.wdWindowStateMaximize;
    </pre>

    3. Case sensitivity is hard to get used to. You expect Intellisense to kick in, but no.

    4. There's no With/End With. Bummer.

    5. The curly braces put too much white space in the code window. Hard to read
    till you get used to those lint specs.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: C# Journey - 2 (2002)

    > wordApp.WindowState = Word.WdWindowState.wdWindowStateMaximize;

    I understand the left side, but why does MS make you fully qualify a constant declaration? The likelihood of a collision with an enumeration like that seems vanishingly small. Can VS .NET use a compiler directive (like #include) to make those "global"? Maybe those aren't intellisensible, if you know what I mean, but it could save on typing...

  3. #3
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: C# Journey - 2 (2002)

    To shorten things up a bit you have to write a wrapper class then refer to the class and the "property" name.
    You define those properties as objects because that's what the PIA expects to be assigned. Method parameters,
    too, have to be of type object.

    Example 1: shortening fully qualified constants

    In a class (my preference: as short a name as possible, like oW) create public static class members:

    public static object wdWindowStateMaximize = Word.WdWindowState.wdWindowStateMaximize;


    Then, in the code you can do this:

    wordApp.WindowState = oW.wdWindowStateMaximize;

    However, when I tried this, it didn't work. But it is supposed to anyway.

    Example 2: Call Word methods:

    object missing = System.Reflection.Missing.Value;
    cbbAppToolBar = (CommandBarButton)oAppToolBar.Controls.Add(1, missing, missing, missing, missing);
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: C# Journey - 2 (2002)

    I think it might take a few seminars before I agree that this is progress. <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

  5. #5
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: C# Journey - 2 (2002)

    I think VSTO will expose the Office object models at least as well as
    VBA. Then, the suffering my team and I are experiencing will end...
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •