excel file stays open

nightrodnightrod Member Posts: 68
Hi all,

i have created a repport to fill in an excel template through the excel buffer.
the report opens the file C:\Temp\template.xls
the data is inserted to the excel file.
than i use the save as funciont to store it as c:\temp\Results.xls
this all works fine except the template.xls file stays open in background.
how can i close this file?

thanks.

Comments

  • krikikriki Member, Moderator Posts: 9,112
    [Topic moved from 'NAV Tips & Tricks' forum to 'NAV/Navision Classic Client' forum]

    You need to create a new function in which there is the command to close the file (or you can add it to the function where you save the file).
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • nightrodnightrod Member Posts: 68
    Ok, but how do i select the open template.xls again?
    because the last active file was the result.xls file.
  • krikikriki Member, Moderator Posts: 9,112
    You already have it. Just after the saving, you can close the sheet.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • nightrodnightrod Member Posts: 68
    hi all,

    thanks for your support. unfortunatly the solution is still not there.
    when i call close function again i got the message:
    Could not invoke the member close. the ole control returned a unknown message.
    SaveWorkBook(FileName : Text[250])
    XlWrkBk.SaveAs(FileName);
    XlWrkBk.Close(FALSE);
    XlWrkBk.Close(FALSE);
    XlApp.Quit;
    CLEAR(XlApp);
    

    i try to explain the problem more clearly:

    -open template.xls
    -modify data
    -save as restults.xls

    the excel file results.xls is closed but the file template.xls stays open in background.
  • krikikriki Member, Moderator Posts: 9,112
    You have 2 times the line : XlWrkBk.Close(FALSE);

    The second close-command generates the error because you just closed it.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • nightrodnightrod Member Posts: 68
    i understand that.
    but how can i close the template.xls file?
  • krikikriki Member, Moderator Posts: 9,112
    1. you open the template.xls
    2. you save it as Results.xls. At the moment you save it as Results.xls, the template.xls HAS BECOME Results.xls.
    3. you close Results.xls. You don't need to close template.xls anymore.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.