Save as CSV - Big PROBLEM

radupoeradupoe Member Posts: 4
bbrown wrote:
Use xlWorkbook.SaveAs(Filename, FileFormat)

I've tryied this, but I got the exception
Microsoft Business Solutions-Navision
This message is for C/AL programmers:

An exception was raised in method SaveAs. The OLE control or Automation server has returned error (HRESULT) -2147352567.
The component did not provide the exception description.

The code is:


XlWrkSht := XlWrkBk.Worksheets.Item(SheetName);
expFileName := recCompanyInfo."Excel Export Path"
+ STRSUBSTNO(savFileName, RANDOM(100000000), '');
expFileFormat:= 'xlCSV';
XlWrkSht.SaveAs(expFileName, '*.CSV');

Where am I wrong?

I also mention that the FileFormat is an Variant in the definition of worksheet functions.

Answers

  • radupoeradupoe Member Posts: 4
    BlackTiger wrote:
    Humans... ](*,)

    You have to pass integer representation of "xlCSV" constant to SaveAs method.

    -

    Please tell me where I can find that integer representation.

    Thank you very much for your fast reply.
  • thaugthaug Member Posts: 106
    Or look at this site which has a ton of these constant values in one place (although it refers to 97, the same constants should carry over):

    http://www.geocities.com/ResearchTriang ... excel8.htm
    There is no data, only bool!
  • radupoeradupoe Member Posts: 4
    Thank you very much, guys!

    \:D/
Sign In or Register to comment.