We have XP Professional, so I'm hoping to get it back. It's another thing
that stopped working after the upgrade. There must be something to tweak.
I did a message box for the Outlook field value and for the Word field
value. Both were correct.
I changed oDoc.PrintOut to oDoc.Display and got the following error message:
"Object doesn't support this property or method: 'oDoc.Display'"
Should I be changing something else too?
Thanks for all your help and patience.
The object browser (F2 in VBA) is your friend. If you look at the Document
object in the Word library, you'll see that it has no Display method, but it
does have an Activate method and Window.Visible property.
You might want to show enough of your code so we can see how you're creating
the document and printing it. Please DO NOT show all the code for filling
the fields; as you said, it's clear that's working.

Signature
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
> We have XP Professional, so I'm hoping to get it back. It's another thing
> that stopped working after the upgrade. There must be something to tweak.
[quoted text clipped - 50 lines]
>> >> >> > doesn't
>> >> >> > contain the information from the form.
Lori_CB - 30 Apr 2009 14:42 GMT
The code I've been referring to is in Outlook, not Word.
Here's what I'm doing when trying to display the Word document
(see <<< comments in the code):
Sub cmdPrint_Click()
Set oWordApp = CreateObject("Word.Application")
If oWordApp Is Nothing Then
MsgBox "Couldn't start Word."
Else
Dim oWordApp
Dim oWordDoc
Dim bolPrintBackground
' Open a new document
Set oDoc = oWordApp.Documents.Add
("\\w2kcbutler\data\eforms\pcrenewal2.dot")
' <<< deleted setting the field values
' Get the current Word setting for background printing
bolPrintBackground = oWordApp.Options.PrintBackground
' Turn background printing off
oWordApp.Options.PrintBackground = False
' Print the Word document
'oDoc.PrintOut <<< commented out
oDoc.Display <<< added
' Restore previous setting
oWordApp.Options.PrintBackground = bolPrintBackground
' Close and don't save changes to the document
'Const wdDoNotSaveChanges = 0 <<< commented out
'oDoc.Close wdDoNotSaveChanges <<< commented out
' Close the Word instance
'oWordApp.Quit <<< commented out
' Clean up
Set oDoc = Nothing
Set oWordApp = Nothing
End If
End Sub
Sue Mosher [MVP] - 30 Apr 2009 16:37 GMT
The code may be in Outlook, but you're using Word objects, so you need to
pay attention to what properties and methods those objects expose. Don't
assume you know what they are; look them up in the object browser.
Did you try using the Activate method I pointed out?

Signature
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
> The code I've been referring to is in Outlook, not Word.
>
[quoted text clipped - 40 lines]
> End If
> End Sub
Lori_CB - 30 Apr 2009 16:50 GMT
I tried the Activate and PrintPreview methods. Each time, nothing happened
when I clicked the Outlook Print button.
Sue Mosher [MVP] - 30 Apr 2009 17:11 GMT
You can also try adding a statement to set the document's
ActiveWindow.Visible property to True.
You might also want to comment out any On Error Resume Next statement so you
can get a better handle on any errors that may be occurring.

Signature
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
> I tried the Activate and PrintPreview methods. Each time, nothing
> happened
> when I clicked the Outlook Print button.
Lori_CB - 30 Apr 2009 19:33 GMT
You are a goddess!
The ActiveWindow.Visible property and PrintPreview let me see the
information is on the form.
I added some message boxes so I know the form was filled out before the
PrintPreview statement and then after the PrintPreview statement.
When it hit the PrintOut statement, it cleared the form then did the actual
print.
Here's the code I used to test it.
' Print the Word document
msgbox "before preview"
oDoc.PrintPreview
msgbox "after preview"
oDoc.PrintOut
msgbox "after printout"
Now, I know it's the PrintOut statement that's causing the problem.
This has been driving me crazy for a week....thank you for saving my sanity.
Sue Mosher [MVP] - 30 Apr 2009 21:03 GMT
Wow, that sounds quite odd, but at least you can print it manually once you
have it in preview. You might want to ask in a Word forum about why the form
fields are clearing.

Signature
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
> You are a goddess!
>
[quoted text clipped - 20 lines]
> This has been driving me crazy for a week....thank you for saving my
> sanity.