Excel Automation Control

daroondaroon Member Posts: 35
edited 2002-05-09 in Navision Financials
Hi i just wanne put some decimals into an Excel-Sheet

with the function

worksheet.range('A1').value := number;

But in excel there are only 2 decimal places all the time, but i really need 5 decimal places. In Navision this Variable has all the decimal places !

What should i do ?

Comments

  • Christian_BuehlChristian_Buehl Member Posts: 145
    Just add a format to your value:

    worksheet.range('A1').Format := '#,##0.00000';

    Depending on language Version you must enter the local number format (e.g. in Germany you need to use '#.##0,0000' instead of upper string.
  • Christian_BuehlChristian_Buehl Member Posts: 145
    Sorry was a little mistake of mine.
    You must use the Property "NumberFormat" instead of "Format" like shown below:

    Range('C:G').NumberFormat := '#.##0,00000';

    Another way is to use the Property NumberFormatLocal. As shown in VBA-Description the NumberFormat should be in international form #,##0.00 while NumberFormatLocal should be the local format code like '#.##,00'. But unlike in VBA in my tests only the local format did work in both properties.

    Range.NumberFormatLocal := '#.##0';
Sign In or Register to comment.