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
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