Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27379

VS 2008 PrintPreview doesn't work on a Word.Document

$
0
0
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:
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()

Edit: There is no error or exception when I call the PrintPReview on the document, just nothing happens.

Viewing all articles
Browse latest Browse all 27379

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>