Create Excel-File - Navision 2.01

Hi everybody,

i have a problem in creating a excel-file in Office-97.

Name DataType Subtype Length
xlsApp Automation 'Microsoft Excel 8.0 Object Library'.Application
xlsBook Automation 'Microsoft Excel 8.0 Object Library'.Workbook
xlsSheet Automation 'Microsoft Excel 8.0 Object Library'.Worksheet
xlsRange Automation 'Microsoft Excel 8.0 Object Library'.Range

CLEAR(xlsApp);
CLEAR(xlsBook);
CLEAR(xlsSheet);
CREATE(xlsApp);
xlsBook := xlsApp.Workbooks.Add(c:\test.xls);
xlsSheet := xlsApp.ActiveSheet;
xlsSheet.Name := 'Tabelle1';
xlsSheet.Range('A1').Value := 'Test';
xlsBook.Save;
xlsBook.Close(FALSE);
CLEAR(xlsApp);

The errormessage is like "test.xls could not be found. please check the path and filename". But i only want to create it.

I hope someone can give me a tip.

thanks
Ralf Beiten

  • Hi

    wrong forum Wink.

    quote:
    Originally posted by h-d.neuenfeldt

    Hi everybody,

    i have a problem in creating a excel-file in Office-97.

    Name DataType Subtype Length
    xlsApp Automation 'Microsoft Excel 8.0 Object Library'.Application
    xlsBook Automation 'Microsoft Excel 8.0 Object Library'.Workbook
    xlsSheet Automation 'Microsoft Excel 8.0 Object Library'.Worksheet
    xlsRange Automation 'Microsoft Excel 8.0 Object Library'.Range

    CLEAR(xlsApp);
    CLEAR(xlsBook);
    CLEAR(xlsSheet);
    CREATE(xlsApp);
    xlsBook := xlsApp.Workbooks.Add(c:\test.xls);
    xlsSheet := xlsApp.ActiveSheet;
    xlsSheet.Name := 'Tabelle1';
    xlsSheet.Range('A1').Value := 'Test';
    xlsBook.Save;
    xlsBook.Close(FALSE);
    CLEAR(xlsApp);

    The errormessage is like "test.xls could not be found. please check the path and filename". But i only want to create it.

    I hope someone can give me a tip.

    thanks
    Ralf Beiten




    Try this:

    ...
    xlsBook := xlsApp.Workbooks.Add;
    xlsBook.SaveAs("YourName");
    ...


    bye

    André
  • Thanks André, it works.
  • Hey,

    the parameter in the Workbooks.Add should be the path to a
    existing Excel-Template File, so this is not what you want.
    Just use xlsApp.Workbooks.Add; without a parameter. To
    The save this workbook, and give it a Name us
    xlsApp.ActiveWorkbook.SaveAs.

    Fred
  • What's cooking - Is Ralf the ghost of Hans Dieter or what?
  • NO HE ISN'TBig SmileBig SmileBig Smile[:I][?]
Related