0

I am trying to save a pipe delimited text file into an excel worksheet format. I am having some errors in the code, below is my code:

TextFile.SaveAs(Filename:=strExcelOutputFilename,
                FileFormat:=Excel.XlFileFormat.xlWorkbookNormal);

Where TextFile is an Excel.Workbook object (Editor's note).

I am having some syntax errors at TextFile.SaveAs portion. Please help me identify any other errors if I have made them, thanks alot!


EDIT: After correction of := to : (Editor's note)

Below is a screenshot of the lines i am having error at, as well as the error list:

enter image description here enter image description here

0

1 Answer 1

1

:= is not a valid C# operator, you just need :

Example:

TextFile.SaveAs(Filename: strExcelOutputFilename, FileFormat: Excel.XlFileFormat.xlWorkbookNormal);

Source: http://msdn.microsoft.com/en-US/library/ms178843.aspx

Sign up to request clarification or add additional context in comments.

4 Comments

after i removed them, ":strExcelOutputFilename, FileFormat" are underlined in red and it seems to have a syntax error in them :/
There's more to debugging than just looking if there's a red line. Open your Error List (View > Error List), try to compile, and read what the error says.
Ah, good! But it doesn't speak much, does it? I don't know what it is at this point, I can't see it. Try removing your FileFormat for a minute, see what it gives you.
It still says ; expected, with strExcelOutputFilename underlined after removing FileFormat

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.