CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 1999
    Posts
    16

    Office automation documetation

    I've tried to find documentation on office automation in particular now for excel, but i've don't find very good document.

    In particular I don't find document on function argument.

    Example :

    If i want modify style of group of cell i don't know what value i must to submit to function SetHorizzontalAlignement see:

    range = sheet.GetRange(COleVariant((LPCSTR)csFirstCell), COleVariant((LPCSTR)csLastCell));
    style = range.GetStyle();
    style.SetHorizontalAlignment( what is a value that i must insert ???????);

    I have found only documentation in help format only for VB but don't for VC++. I've also Msdn library, but there isn't so much.

    Can u help me

    Thanks

    Dyensì Software
    Antonio Patarozzi


  2. #2
    Guest

    Re: Office automation documetation

    You're right...there is not much documentation.
    However, you can use the VB help to get the values of the constants passed to the functions. If you open the Visual Basic Editor from Excel (from Excel menu: Tools, Macro, Visual Basic Editor), and then use the Object Browser (from Visual Basic Editor menu: View, Object Browser) to search for the function.

    Referring to your example, in the Object Browser type Style as the keyword for the search, or just scroll to find Style in the Classes pane and click on it. The Horizontal Alignment property will be listed as a Member of 'Style'. If you click on HorizontalAlignment in member of 'Style' pane, you will notice in the bottom pane, it reads:

    Property HorizontalAlignment As XlHAlign
    Member of Excel.Style

    where XlHAlign is a link. If you pass the mouse over it, it becomes a hand, so click on XlHAlign, and the Object Browser will jump to XlHAlign with all its members.
    The members listed are the constants that may be used for the HorizontalAlignment property. So, if you want the alignment to be centered say (xlHAlignCenter), click on xlHAlignCenter in the Members of 'XlHAlign' pane. Again, notice the bottom pane. It now reads:

    Const xlHAlignCenter = -4108 (&HFFFFEFF4)
    Member of Excel.XlHAlign

    So '-4108' is the value you need to put into the function.
    Your code would then look like:

    range = sheet.GetRange(COleVariant((LPCSTR)csFirstCell), COleVariant((LPCSTR)csLastCell));
    style = range.GetStyle();
    style.SetHorizontalAlignment(COleVariant((short)-4108)); //xlHAlignCenter = -4108



    Good luck...hope that helps.


  3. #3
    Join Date
    May 1999
    Posts
    16

    Re: Office automation documetation

    thanks for your answer.

    But microsoft cannot create also a .h files with this costants when she create interface classes for excel ?????

    A time i don't understand the filosophy of microsoft.

    Thanks again and sorry for my english.

    Thanks

    Dyensì Software
    Antonio Patarozzi



Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured