Excel automation set horizontal align.

How can I set horizontal align of a cell in a Excel sheet? I have found out font.bold can be set like this and would like to set the align property likewise: Sheet.Range(‘A’ + FORMAT(ExcelRowNo)).Font.Bold := TRUE; Thankyou, Fredrik

The best way is, create a macro format the cell and stop the macro and then go in that macro edit and copy the code.

Did try that, but CAL refuses to compile. Could you give some sample code/syntax? //Fredrik

LEFT: sheet.range(…).HorizontalAlignment := -4131 Center: sheet.range(…).HorizontalAlignment := -4108 Right: sheet.range(…).HorizontalAlignment := -4152 If you got the vba code you have to make some modifications. Navision dont know the vba constants like xlleft, xlright, xlcenter. Use the objekt-libary to get the values. Bye(‘Stefan’);

show me the code, may be i can help u, i tried at my end; it is working at my end, here are some lines. CREATE(xl); xl.Visible(true); xlwb := xl.Workbooks.add; xlsheet := xlwb.ActiveSheet; xlsheet.Range(‘A1’).Select; xlsheet.range(‘A1’).font.bold:=true; xlsheet.range(‘A1’).Orientation :=-4166 // xlVertical

For example I’d like to align the cell to the right. Did try to use the property HorizontalAlignment without success as below. In some way I have misunderstood the syntax. Sheet.Range(‘C’ + FORMAT(ExcelRowNo)).Select; Sheet.Range(‘C’ + FORMAT(ExcelRowNo)).Value := Amount; Sheet.Range(‘C’ + FORMAT(ExcelRowNo)).HorizontalAlignment := ‘xlRight’; //This do not work //Fredrik

I read in another thread about using the macro function in excel and then read the vb code of the macro… that have helped me a lot the past days to get a report done. Just start recording a macro in a sheet and then do what u want the automation to do and then end the macro. Then read the macro with the Visual Basic Editor… Try it and u will be hooked :wink:

dear frgusto, you have to pass the integer value not the string, pass it like this, it works Sheet.Range(‘C’ + FORMAT(ExcelRowNo)).HorizontalAlignment := -4152;

I’m grateful! Thankyou all. //Fredrik