Navision Excel Automation Merge Cells(Number, Number)

MaisteraMaistera Member Posts: 3
Hello,

in VBA there i have a Code like

Range(Cells(1,5),Cells(1,6)).Merge

I searched in the Internet for translate it into Navision Excel Automation.

I've only found something like that:
Range('A10:A11').Merge

But i have to take integer Values to find the right cell.

If there is a Subject that allready exists you may show me the link, i found nothing.


Thank you!

Comments

  • chichi Member Posts: 17
    Hi

    Is the following code suitable to your request?

    iCell := Cell[colBegin] + FORMAT(rowBegin) + ':' + Cell[colEnd] + FORMAT(rowEnd);
    xlSheet.Range(iCell).Merge;

    with variables as: icell : Text DataType
    colBegin, rowBegin, colEnd, rowEnd : Integer DataType
  • MaisteraMaistera Member Posts: 3
    Im think it's not.

    What is Cell[] ?
  • chichi Member Posts: 17
    Sorry for missing. Here is the way I used:
    In a Codeunit:
    - Declare "Cell" global variable (DataType = Text and Dimensions property = 800).
    - Create "SetChar" function and declare the following local variables: i, j, k (DataType = Integer), c1, c2 (DataType = char).
    SetChar()
    
    k := 1;
    i := 0;
    WHILE (i <=26) DO BEGIN
      j := 1;
      WHILE (j <= 26) DO BEGIN
        IF i = 0 THEN BEGIN
          c1 := 64 + j;
          Cell[k] := FORMAT(c1);
        END ELSE BEGIN
          c1 := 64 + j;
          c2 := 64 + i;
          Cell[k] := FORMAT(c2) + FORMAT(c1);
        END;
        j := j + 1;
        k := k + 1;
      END;
      i := i + 1;
    END
    
    - Call SetChar function before using the code in my previous post:
    iCell := Cell[colBegin] + FORMAT(rowBegin) + ':' + Cell[colEnd] + FORMAT(rowEnd);
    xlSheet.Range(iCell).Merge;
    
    BTW, the following may be helpful in case of using Excel Buffer.
    http://saurav-nav.blogspot.in/2012/05/n ... merge.html
Sign In or Register to comment.