Locked *** Saving spreadsheet into HTML file format ***

  • Thursday, May 14, 2009 10:36 AM
     
     
    Dear Sir/Madam,

    I am using Visual Studio 2008, VB to write a little exe program to manipulate an EXCEL spreadsheet.  One of the task is to save a particular sheet to a HTML file.  I use the following three lines of code to save the sheet "TestSuite" to a HTML file "N:\Result.html". 

        Dim xlSheet As Microsoft.Office.Interop.Excel.Worksheet

        xlSheet = CType(xlBook2.Worksheets("TestSuite"),  Microsoft.Office.Interop.Excel.Worksheet)

        xlSheet.SaveAs("N:\Result.html", FileFormat:=XlFileFormat.xlHtml)


    But my Visual Studio comes up an error "Name 'XlFileFormat' is not declared" .  I think XlFileFormat is included in Microsoft.Office.Interop.Excel namespace.  I already add Microsoft.Office.Interop.Excel as reference to my solution.  But VS still come up the same error message.  What should I do?  Do I have the wrong version of VS or .Net framework?

    Look forward to hear from you.  Many many thanks.

    Waiman
    Waiman ( www.DNV.com )

All Replies

  • Thursday, May 14, 2009 10:43 AM
     
     Answered
    Sorry, waste all your time.  I find a solution.  Use the fill namespace path, then Visual Studio will not complain.


    xlSheet.SaveAs("N:\Result.html", FileFormat:=Microsoft.Office.Interop.Excel.XlFileFormat.xlHtml)



    Many thank you for reading this question.

    Waiman
    Waiman ( www.DNV.com )
    • Marked As Answer by Waiman Li Thursday, May 14, 2009 10:43 AM
    •  
  • Wednesday, April 18, 2012 5:18 AM
     
     
    never mind, finding right soluiton in  7 minutes deserves an award, all the best :)