Results 1 to 3 of 3

Thread: How to save excel sheet as html from VB

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2007
    Posts
    4

    How to save excel sheet as html from VB

    Hi Guys,

    I am a newbee as far as VB is concerned. I am trying to save an excel sheet as html file from MS Visual Studio - VB, but I am getting error. A sample of my code is

    Sub create_html()

    Dim application As Microsoft.Office.Interop.Excel.Application

    Dim book As Microsoft.Office.Interop.Excel.Workbook

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

    Dim file_format As HtmlDocument

    .....

    Sheet.SaveAs("D:\Documents and Settings\Sanket\My Documents\chart.html", file_format)

    End Sub()

    Do I need to 'Add Reference' for the project ? What should be done ?

    thanks,

    Sanket

  2. #2
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: How to save excel sheet as html from VB

    Yes, if you use office automation (as what you're doing now), you need to add a reference to the Microsoft Office xx Object Library (where xx is the version number) found in the COM tab. Keep in mind that anyone who uses your application will also need MS Office of the same (or higher) version installed in their machine.
    Another way to do this is to use ADO.Net... Just read your excel file into a datatable then write the table to an xml file... This requires no MS Office installed in the machine.

  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2007
    Posts
    4

    Re: How to save excel sheet as html from VB

    Quote Originally Posted by stanav
    Yes, if you use office automation (as what you're doing now), you need to add a reference to the Microsoft Office xx Object Library (where xx is the version number) found in the COM tab. Keep in mind that anyone who uses your application will also need MS Office of the same (or higher) version installed in their machine.
    Another way to do this is to use ADO.Net... Just read your excel file into a datatable then write the table to an xml file... This requires no MS Office installed in the machine.
    Hi Stanav,
    Thanks a lot for the reply. But I have already tried that. I have included "MS Office Object" and also "MS.Excel.Interop..." as my references. The problem is not in creating excel file 'programmatically' but in saving it as html. Is there any specific refernce for that ? I think there is some problem in the way I have defined and used file format[i.e. HTML] in my code.Please have alook at the code lines that I posted.

    I cant copy the execl into database because I have a chart in my excel sheet(actually, all I want to do is to have the chart). Is there still an alternative?

    Thanks a ton!!!
    Sanket

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width