Error When Running CloseBook Function in Exporting to Excel

donnaprietodonnaprieto Member Posts: 3
edited 2014-03-04 in NAV Three Tier
Hi,

Is there anyone here who already encounter this kind of error in exporting to excel in NAV2013?



I'm encountering this error when I tried to run my customized report for BIRForm2307 to Update an excel worksheet. I've tried to debug it and it stops at the code recExcelBuffer.CloseBook;

Kindly help me please on how to fix this issue, it almost 1 week since I've been trying to solve this bug. ](*,)

1. Code that runs the excel buffer. The error prompts on the third line below

recExcelBuffer.UpdateBook(txt2307TemplatePath,SheetName);
recExcelBuffer.WriteSheet('',COMPANYNAME,USERID);
recExcelBuffer.CloseBook;
recExcelBuffer.OverwriteAndOpenExistingExcel(txt2307TemplatePath);
recExcelBuffer.GiveUserControl;


2. CloseBook Fuction

IF NOT ISNULL(XlWrkBkWriter) THEN BEGIN
XlWrkBkWriter.ValidateDocument;
XlWrkBkWriter.Close;
CLEAR(XlWrkShtWriter);
CLEAR(XlWrkBkWriter);
END;

IF NOT ISNULL(XlWrkBkReader) THEN BEGIN
CLEAR(XlWrkShtReader);
CLEAR(XlWrkBkReader);
END;



Your suggestions and comments will much appreciated. [-o<


Thanks,

Donna

Answers

  • geordiegeordie Member Posts: 655
    Maybe a silly suggestion...have you checked in NAV the source fields used to populate data in Excel?
    I guess there is some non-printable character somewhere which causes the problem, you can find it out with a loop such as:
    FOR i := 1 TO STRLEN(YourTable.TextField) DO BEGIN
      MyIntVar := YourTable.TextField[i];
      IF MyIntVar > 128 THEN
        ERROR(...);
      END;
    
  • donnaprietodonnaprieto Member Posts: 3
    hi Geordie,

    thanks for that.
    I already resolved the bug, you're right that its from the function I used to populate data in Excel.
    The error occurs in the field that does not have any value where it is pass to a function that needs to be separated by cell.
    Whew. \:D/

    Thanks again.

    Donna
  • geordiegeordie Member Posts: 655
    Glad it worked, remember to mark the topic as solved :wink:
Sign In or Register to comment.