Excel automation

MarcelMarcel Member Posts: 26
edited 2010-04-20 in Navision Financials
I'm using automation to export the item sales to Excel. It's working perfect but when the sales are negative, the exported value is formated as text in Excel.
(€ 1248- instead of -1248).

I tried to solve it with the following code:

Sheet.Range('B:M').NumberFormat := '#.##0;-#.##0';

But this is not working. Does anyone know the solution for this problem?
Best Regards,

Marcel Bierens

Comments

  • ReportReport Member Posts: 4
    Hi Marcel,

    I am sorry not to respod to your initial question, but after what you have wrote you might be able to help me with a little automation problem ( I am in the beginnings...).
    I am trying to export sales data to excel and I just don't find the function to tell excel with c/side code to swith to the next cell in a column once it has filled it with data. The Range command does not accept variables...
    Help is really appreciated...
    Never change a running system...
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    Report (or Alexander),

    When you use this
    xlsheet.Range('A' + FORMAT(i)).Value := 'some value';
    you can use the i variable to move to the next row.
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • ReportReport Member Posts: 4
    Thanks alot Luc Van Dyck,

    I have tried every possible order of these commands and FORMAT but it was the '+' that made all the difference...

    Thank God for the Forums...
    Never change a running system...
  • jurjanjurjan Member Posts: 1
    I know, it's been 8 years.
    but, since I've just had the same problem and solved it (for my case at least) I thought: let's post the solution here.

    Worksheet.Range('A'+FORMAT(Row)).Value := format(FieldName, 0, 0);
    Worksheet.Range('A:A').NumberFormat := '#.##0;-#.##0';

    what this does is make a string from the number in a standard format.
    then we place that in the cell.
    Afterwards we give the cell the format we want it to have in Excel.
Sign In or Register to comment.