Custom form prints blank Word template without field values...

M

Matt Overbee

Hello,

I have a user who has trouble printing one of our custom forms. When
he prints it only prints a blank Word Template without any of the
values entered by the submitter.

It's a fairly simple form that prints out the form values using a
custom Print button that prints to a Word Template. We are running
Windows XP Pro. and Office 2003. Nobody else seems to be having this
problem but him.

Below is some of the code from the form:

Sub cmdPrint_Click
Dim oWordApp

Set oWordApp = CreateObject("Word.Application")
If oWordApp Is Nothing Then
MsgBox "Could not print because Word will not start."
Else
Dim oDoc
Dim bolPrintBackground

'Open the template
Set oDoc = oWordApp.Documents.Open("S:\AGIInkReq.dot")

strDate = Now
oDoc.FormFields("txtDateRequested").Result = strDate

strDateDue = Item.UserProperties.Find("DateCompleted").Value
If strDateDue <> "1/1/4501" Then
oDoc.FormFields("txtDateCompleted").Result = strDateDue
End If

Set myNS = Application.GetNameSpace("MAPI")
Set myUser = myNS.CurrentUser
oDoc.FormFields("txtPlanner").Result = myUser

strJobNo = Item.UserProperties.Find("JobNo").Value
oDoc.FormFields("txtJobNo").Result = strJobNo

'--- a bunch of fields in between

bolPrintBackground = oWordApp.Options.PrintBackground
oWordApp.Options.PrintBackground = False

oDoc.PrintOut

oWordApp.Options.PrintBackground = bolPrintBackground

Const wdDoNotSaveChanges = 0
oDoc.Close wdDoNotSaveChanges

oWordApp.Quit

Set oWordDoc = Nothing
Set oWordApp = Nothing
End If
End Sub
---------------

This is one of our older forms so I thought maybe the code was
outdated but it works for everyone else just fine, so I couldn't
figure out.

Any help or guidance would be greatly appreciated.

Thank You,
Matt
 
S

Sue Mosher [MVP-Outlook]

Best troubleshooting technique in this case may be to walk through the code
with the script debugger on that user's machine.
 
M

Matt Overbee

Sue,

Thanks for the reply. The form runs through the code and prints
without any errors or anything like it's working just fine. Is there
some kind of software or setting that would disable the ability for
Outlook to send info. to Word?

Thanks again,
Matt
 
S

Sue Mosher [MVP-Outlook]

So you see text in the printed document, just not the Outlook data?

I'd make sure that you have Option Explicit at the very top of your form
code in the declarations section. That will make any obvious issues with
variable names stand out immediately.

Also, try using the syntax Item.UserProperties("DateCompleted") instead of
Item.UserProperties.Find("DateCompleted").Value throughout.
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



Matt Overbee said:
Sue,

Thanks for the reply. The form runs through the code and prints
without any errors or anything like it's working just fine. Is there
some kind of software or setting that would disable the ability for
Outlook to send info. to Word?

Thanks again,
Matt

"Sue Mosher [MVP-Outlook]" <[email protected]> wrote in message
Best troubleshooting technique in this case may be to walk through the code
with the script debugger on that user's machine.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top