Thanks Arne,
It works now.
I have one more problem/question. I hope you can help me out.
I have a templete (WORD templete) : MyTemplete.dot
This is a 1 page templete with several bookmarks.
I want to "print out" all my data/record with MyTemplete file via VB.Net.
1 page for 1 record, but all of the pages should be in 1 document.
Ex. : 50 records mean 50 pages WORD document.
The problem is : What should I do to make 1 record 1 page ?
Thanks in advance,
Regards,
Joachim.
Below is my code :
====
Private sub PrintwithWord()
Dim objWord As Word.Applicatio n
Dim objDocument As Word.Document
objWord = CType(CreateObj ect("Word.Appli cation"), Word.Applicatio n)
objDocument = CType(objWord.D ocuments.Open(A ppPath & "MyExamen.dot") , Word.Document)
For i = 1 To TotalRecords
ReadRecord()
objDocument = CType(objWord.D ocuments.Open(A ppPath & "MyTempelte.dot "), Word.Document)
objWord.Visible = True
If objDocument Is Nothing Then
MsgBox("The Templete file not fond !", MsgBoxStyle.Cri tical, "Error")
Exit Sub
End If
objWord.ActiveD ocument.Bookmar ks.Item("Bookma rks1").Range.Te xt = MyField1
objWord.ActiveD ocument.Bookmar ks.Item("Bookma rks2").Range.Te xt = MyField2
objWord.ActiveD ocument.Bookmar ks.Item("Bookma rks3").Range.Te xt = MyField3
objWord.ActiveD ocument.Bookmar ks.Item("Bookma rks4").Range.Te xt = MyField4
objWord.ActiveD ocument.Bookmar ks.Item("Bookma rks5").Range.Te xt = MyField5
objDocument.Pri ntPreview()
objDocument.Sav eAs(UserPath & "\" & "-Text" & ".doc")
objDocument.Clo se()
Next
objWord.Visible = False
CLoseWord()
End Sub
=====
"Arne Janning" wrote:
Hi Joachim,
seems you have Office XP PIAs installed
http://www.microsoft.com/downloads/d...4-01FEBA508E52
It should be
Microsoft.Offic e.Interop.Word. ApplicationClas s
Microsoft.Offic e.Interop.Word. DocumentClass
Understanding the Word Object Model from a .NET Developer's Perspective:
http://msdn.microsoft.com/vstudio/of...wordobject.asp
Cheers
Arne Janning