Hi!
I have managed to fill a Word template within my code and I can print it successfully, but I cannot show a PrintPreview. Here's my code:
Edit: There is no error or exception when I call the PrintPReview on the document, just nothing happens.
I have managed to fill a Word template within my code and I can print it successfully, but I cannot show a PrintPreview. Here's my code:
Code:
Dim oWord As New Word.Application
Dim oDoc As Word.Document
oWord = CreateObject("Word.Application")
oDoc = oWord.Documents.Add("C:\pathtomytemplate\Template.dot")
'Then I fill the bookmarks in the template by
Dim sqlCmd As New OleDbCommand
sqlCmd.Connection = newConn
sqlCmd.CommandText = "select * from document where id = " & CStr(GetID()) & ""
Dim rdoc As OleDbDataReader
rdoc = sqlCmd.ExecuteReader()
rdoc.Read()
oDoc.Bookmarks.Item("doc_num").Range.Text = rdoc("document")
'Then I want to preview the document, which does nothing visible
oDoc.PrintPreview()
'However the next command prints out correctly
oDoc.PrintOut()