Excel automation border

gedasgedas Member Posts: 87
edited 2010-01-13 in Navision Financials
Hi,
What i do wrong??
Why string: autSheet.Range('A7').Borders.LineStyle:='xlContinuous'; get automation error, when other strings: autSheet.Range('A7').Font.Bold:=TRUE; are OK???

RGDS
GB

Comments

  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    I use following code to get a border in Excel:

    function Border(Cell_No : Text[7]; Thickness : Integer)
    xlSheet.Range(Cell_No).BorderAround(10,Thickness);
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • gedasgedas Member Posts: 87
    Thanx Luc,
    Its work.
    But i've never thougt some automations must be in function, and not working directly.
    GB
  • John_TegelaarJohn_Tegelaar Member Posts: 159
    You don't need to use a function per se. But you are overlooking that Excel often uses named constants instead of values. Named constants are in most cases recognized by the first few letters of the name - 'xl' = Excel, 'wd' = Word, 'pj' = MS Project, 'cdl' = Common Dialog and so on.

    To find the value of such a constant, go to the VBA editor in Excel, call up the References box (F2) and type the name of the constant in the search field. When found, the value is shown at the bottom of the window.

    John
  • [TweaK][TweaK] Member Posts: 14
    Navision: 5 SP1 (Native, not SQL)
    I am using this Excel.dll as automation: 'Microsoft Excel 11.0 Object Library'
    Problem: Setting Left/Right/Top/Bottom border.

    Setting a BorderArround was not much of a Challenge..
    But right now i'm going nuts trying to set a specific type of border..
    * BORDER / ENUMERATION
    - Left Border / 7
    - Right Border / 10
    - Top Border / 8
    - Bottom Border / 9
    - Diagonal Up Border / 6
    - Diagonal Down Border / 5

    I have added the Excel.dll as a reference to VB.NET to see what paremeters the "Borders" function provides.
    And as it seems you should be able to do this:
    * autExcel.Borders(ENUMERATION).LineStyle := 1 ;

    Also, according to VB.NET, the ENUMERATION is a "hiddenmemberparam".
    And so, Navision keeps telling me that "maximum of 0 parameters was exceeded".
    Navision does not accept the "Borders(ENUM)...", it only accepts "Borders..." (no parameters)
    So my question is, how in gods name do i, for example, set a Left Border.

    Is it even possible in Navision with this dll?
    Any and All help is welcome!
  • [TweaK][TweaK] Member Posts: 14
    Hmm,..
    Besides navision beïng retarted and not allowing you to use a dll's full functionality, there is a way to set for example a Left Border ..

    Default Border Arround:
    autRange.BorderAround

    Specific Type of Border:
    autRange.Borders.Item(lintBorderIndex);

    And here are the Enumerations:
    CASE (loptBorder) OF
    loptBorder::"Edge Left" : lintBorderIndex := 7;
    loptBorder::"Edge Right" : lintBorderIndex := 10;
    loptBorder::"Edge Top" : lintBorderIndex := 8;
    loptBorder::"Edge Bottom" : lintBorderIndex := 9;
    loptBorder::"Inside Horizontal" : lintBorderIndex := 12;
    loptBorder::"Inside Vertical" : lintBorderIndex := 11;
    loptBorder::"Diagonal Up" : lintBorderIndex := 6;
    loptBorder::"Diagonal Down" : lintBorderIndex := 5;
    END;
Sign In or Register to comment.