export data from vb.net into ms-word

i need a simple example that demonstrate how to export data and images (create tables) from vb.net to MS-Word.
all i was able to find is how to export data into excell.
thanks for the help.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hello mte01,

you could look at a small sample from
source: http://experts.about.com/q/VB-NET-3306/Automation-Inserting-table-MS.htm
Dim appMSWord As New Microsoft.Office.Interop.Word.Application
Dim docNew as Microsoft.Office.Interop.Word.Document = appMSWord.Documents.Add()

appMSWord.Visible = true

'Once the application is launched and you have a document open, use the following code:
tblTable = appMSWord.ActiveDocument.Tables.Add(appMSWord.Selection.Range, n, m)"

'To set the text of cells use the code:
tblTable.Cell(Row, Column).Range.Text = "Text" '"1, 1" represents row 1, column 1

a more general sample of automating word from vb.net
source: http://support.microsoft.com/?kbid=303294

hope this helps a bit
mte01Author Commented:
hi bruintje
this example: http://support.microsoft.com/?kbid=303294 is working but it doesnt help creating word documents, it only set the properties of the word document.
and the first example is not working, for they dont say the type of the object tblTable, and they have a problem with the reference thing that i couldnt solve...
i need a simple example that insets text and images into a word document..
any more idea's ??
thanks again
are your images coming from the application or just from disk and need to be linked into the document?
Build an E-Commerce Site with Angular 5

Learn how to build an E-Commerce site with Angular 5, a JavaScript framework used by developers to build web, desktop, and mobile applications.

mte01Author Commented:
i have the images on the disk, but im building a report.. so dont know if it would be nice to give the client a folder that contain the word document and a folder containing the images (like the HTML)
dont know if this answers ur question?
sorry i was not clear i meant

was this what you're looking for

1. create new document
2. insert some images from disk
3. insert some text from your application
4. save the document and send it to the client

mte01Author Commented:
yeah exactly
i mixed the code from the MS article with some late binding instead of referencing this makes using intellisense moot but you have no problem with versions on the client side

this was only a button on a form

  Private Sub Button1_Click(ByVal sender As System.Object, _
                            ByVal e As System.EventArgs) _
                            Handles Button1.Click
    Dim oWord As Object
    Dim oDoc As Object
    Dim oTable As Object
    Dim oSelection As Object
    Dim strValue As String

    'Create an instance of Word and make it visible.
    oWord = CreateObject("Word.Application")
    oWord.Visible = True
    'Create a new document
    oDoc = oWord.Documents.Add()
    oSelection = oWord.Selection.Range
    'Get a new table of 2 x 2
    oTable = oDoc.Tables.Add(oSelection, 2, 2)
    'Insert a new string into cell 1,1
    strValue = "hello there"
    oTable.Cell(1, 1).Range.Text = strValue
    oSelection = oTable.Cell(1, 2).Range
    oSelection.InlineShapes.AddPicture(FileName:= _
      "C:\Documents and Settings\Username\My Documents\My Pictures\bull.gif", _
      LinkToFile:=False, SaveWithDocument:=True)

    'Clean up. We'll leave Word running.
    oSelection = Nothing
    oTable = Nothing
    oDoc = Nothing
    oWord = Nothing

  End Sub

if you want intellisense then using a reference is easier

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mte01Author Commented:
thanks it's working perfectly.. just one more request
to insert notmal text (without tables) and if i can set this text to bold italic....
and if u know someplace where i can learn to set the properties of the font and how to do other things, i cant seem to find a tutorial on such things.
well you could look at a sample http://www.kdkeys.net/forums/thread/691.aspx

but most of the time i use the macro recorder in word or excel to get to the VBA code and port it to other languages

with the recorder doing the initial work as i did for the sample above and the object browser to see everything in the object models its enough to start with

the vb editor in word is opened by using ALT+F11
the object browser window in that editor is F2

great place on the net with a great editor :)

mte01Author Commented:
it's just that i didnt understand the way the macro works... (sorry)
but the first example was helpfull.
anyways thanks bruintje for your help
thanks for the grade, be sure to check out the msdn site links above they will help a bit
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.