How to use late-binding in VB.NET (anyone who knows: please help!!)

Hi, I have made a program in VB.NET that is able to put some text that a user puts in a textbox into a Word document.
I do this with a Word template with bookmarks, where I want the programm to insert the text.

I used early binding and used Word9 object library. (Word 2000).
**********************************************************************
Dim wordapp As Word.Application
Dim bkmrkname(999) As Word.Range

wordapp = CType(CreateObject("Word.Application"), Word.Application)
wordapp.Documents.Add(Template:=apppath & "template.dot")

For a = 0 to 5
bkmrkname(a) = wordapp.ActiveDocument.Bookmarks.Item("name").Range
Next a

bkmrkname(a).Text = txtuserinput.Text(a)
***********************************************************************
But I want to make the program also to work with Word '97.
So I try'd this:
***********************************************************************
Dim wordapp As Object
Dim bkmrkname(999) As Word.Range

wordapp = CType(CreateObject("Word.Application"), Object)
wordapp.Documents.Add(Template:=apppath & "template.dot")
***********************************************************************
But just changeing the declaration to "Object" does not work!

Can someone please help me!!!
This is the only thing I need to know to finish my application, so I really appreciate it if u can help me.

Thanks,

VB Newbie

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories