Solved

How can i write HTML to a doc file???

Posted on 2004-10-05
3
207 Views
Last Modified: 2010-04-23
I have the next code for generating a doc file.

        Dim msword As Word.Application
        Dim msDoc As Word.Document
        Dim a_text As String
        a_text = "TEXT to be written!!! :)"
        msword = New Word.Application
        msDoc = msword.Documents.Add
        msDoc.Content.Text = a_text                    'write text to the doc file
        msDoc.SaveAs("c:\01.doc")                      'save the doc file
        msDoc.Close()
        msDoc = Nothing
        msword.Quit()
        msword = Nothing

In stead of writing oly text i would like to write html code that will be interpreted by word and desplayed like in IE. Is this possible???

Or how can i make tables into this word document? Draw lines... and make table outline invisible???

Thanks.
0
Comment
Question by:drcyrus3d
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 10

Accepted Solution

by:
prakash_prk earned 500 total points
ID: 12274747
Try this codes
----------------------
 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        ConvertToWord("<BODY BGCOLOR=RED> HAI </BODY>", "d:\hai.doc")
    End Sub
----------------------
    Private Function ConvertToWord2(ByVal SourcePath As String, ByVal DestPath As String)
        Dim msword As Word.Application
        Dim msDoc As Word.Document
        Dim a_text As String
        msword = New Word.Application
        msDoc = msword.Documents.Open(SourcePath)
        MsgBox(msDoc.Content.Text) 'write text to the doc file
        msDoc.SaveAs(DestPath, Word.WdSaveFormat.wdFormatDocument)                     'save the doc file
        msDoc.Close()
        msDoc = Nothing
        msword.Quit()
        msword = Nothing
    End Function
--------------------------------
    Private Function ConvertToWord(ByVal HtmlContent As String, ByVal DestPath As String)
        Dim msword As Word.Application
        Dim msDoc As Word.Document
        Try
            Dim MyWriter As New System.IO.StreamWriter(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) & "\..\temp\temp1.html")
            MyWriter.WriteLine(HtmlContent)
            MyWriter.Close()

            msword = New Word.Application
            msDoc = msword.Documents.Open(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) & "\..\temp\temp1.html")

            msDoc.SaveAs(DestPath, Word.WdSaveFormat.wdFormatDocument)                     'save the doc file
            msDoc.Close()
            msDoc = Nothing
            msword.Quit()
            msword = Nothing
            MsgBox("Success")
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    End Function
-----------------------------------
Regards
Prakash
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question