How we can do Export to Excel with color

devjangradevjangra Member Posts: 4
Hi,
I have a problem, i want to export to excel with any field in color in Nav. 4.0. I know how to export to excel but i don't know how to make it color. Please suggest me. I use "Excel Buffer' table for export to excel.

Thanks
Devjangra

Comments

  • garakgarak Member Posts: 3,263
    it's simple. to know what you must do in Navision (here u use Automation EXCEL) do following:

    Open Excel and recording a Marco. Than colour your field. Stop the Macro recording. See the Macro code. Now you know, how you can colour a field. These vb code you must "transfer" (not directly) to your C/AL (Automation) Code.

    regards. (Hope it's comprehensible)
    Do you make it right, it works too!
  • HanenHanen Member Posts: 281
    Hello,

    Can you explain more?????
    I'm using a macro and I call it from navision using xlApp.Run(MacroName);
    but I got an error msg at the end :cry:

    Any help???

    Thanks
    Regards

    Hanen TALBI
  • SaalekSaalek Member Posts: 181
    1- Record a new Macro.
    2- Change colour to a field.
    3- Stop the macro.
    4- View macro code.
    5- Copy macro code and paste it in Navision.
    6- Change the code to adapt it to Navision.

    Bye
  • SPost29SPost29 Member Posts: 148
    If you want to continue to use the excel buffer table.
    Add a field Color as an integer or option .
    then look at how the function "CreateSheet" handles Bold,Italic and Comment

    You can use similar code to handle color, as colorindex is a property of the Font object in Excel.

    Hope this helps
    Steve
  • HanenHanen Member Posts: 281
    I tried with macro as you said but it didn't work, I got an error message telling that macro are desactivated................
    What shall I can I do????
    Regards

    Hanen TALBI
  • SaalekSaalek Member Posts: 181
    Hi

    The instruction you need is that
    XlSheet.Range('FIELD').Interior.ColorIndex:= number;
    

    Number = 3 - Red
    6 - Yellow
    4 - Green
    5 - Blue
    1 - Black

    Bye
Sign In or Register to comment.