Word Application Object
Posted on 2003-03-12
I am trying to preview a Word document from a VB6 application. I have added a reference to the Microsoft Word 9.0 Object Library, and created a sub called PreviewReport. I am using Word 2000 running on a WindowsXP machine. I am also doing the application development on WindowsXP.
The code runs without errors, and I can see Word load and unload in the Windows Task Manager as the sub executes. However, the PrintPreview command simple does nothing. When I step through the code, it passes right over it as if it is executing, but the document does not display.
Can anyone tell me what I am doing wrong?
The following code is what I have for my sub...
Private Sub PreviewReport
Dim wrdApp As Word.Application
Dim wrdDoc As Word.Document
Dim wrdSel As Word.Selection
Set wrdApp = New Word.Application
Set wrdDoc = wrdApp.Documents.Add
Set wrdSel = wrdApp.Selection
Set wrdSel = Nothing
Set wrdDoc = Nothing
wrdApp.Visible = True
Set ardApp = nothing