B
Bill Billmire
I have a custom (message based) form where I want to print the field data. I
have it working correctly for all fields except the "checkboxes". The loop
appears to iterate through all the bookmarks in the template correctly and
fills in the bookmarks with the exception of the checkboxes, instead of the
checkboxes being "checked" they are prefixed with either True or False
depending on the state of the checkbox in the Outlook form... I want the
checkboxes on the word template to be either checked (or not checked) as
represented on the Outlook form.
Code below...
'----------------------Printing Routine------------------------
Dim objWord
Dim strTemplate
Dim strField
Dim strField1
Dim objDoc
Dim objMark
Dim mybklist
Dim counter
Sub cmdPrint_Click()
Item.Save
Set objWord = CreateObject("Word.Application")
' Put the name of the Word template that contains the bookmarks
strTemplate = "form.dot"
' Location of Word template; could be on a shared LAN
strTemplate = "\\server\folder\" & strTemplate
Set objDoc = objWord.Documents.Add(strTemplate)
Set mybklist = objDoc.Bookmarks
For counter = 1 to mybklist.count
Set objMark = objDoc.Bookmarks(counter)
strField = objMark.Name
If strField = "SentField" then
strField1 = CStr(Item.SentOn)
If strField = "ElectWork" then
ObjMark("ElectWork").CheckBox.Value = True
ElseIf strField = "Furniture" then
ObjMark("Furniture").CheckBox.Value = True
ElseIf strField = "GenConstruction" then
ObjMark("GenConstruction").CheckBox.Value = True
ElseIf strField = "Other" then
ObjMark("Other").CheckBox.Value = True
ElseIf strField = "PartitionRecon" then
ObjMark("PartitionRecon").CheckBox.Value = True
ElseIf strField = "PersonnelMove" then
ObjMark("PersonnelMove").CheckBox.Value = True
ElseIf strField = "Telecomm" then
ObjMark("Telecomm").CheckBox.Value = True
End If
Else
strField1 = Item.UserProperties(strField)
End If
objMark.Range.InsertBefore strField1
'stop
Next
msgbox "Printing to " & objWord.ActivePrinter
objDoc.PrintOut 0
objWord.Quit(0)
' Clean up
Set objDoc = Nothing
Set objWord = Nothing
End Sub
have it working correctly for all fields except the "checkboxes". The loop
appears to iterate through all the bookmarks in the template correctly and
fills in the bookmarks with the exception of the checkboxes, instead of the
checkboxes being "checked" they are prefixed with either True or False
depending on the state of the checkbox in the Outlook form... I want the
checkboxes on the word template to be either checked (or not checked) as
represented on the Outlook form.
Code below...
'----------------------Printing Routine------------------------
Dim objWord
Dim strTemplate
Dim strField
Dim strField1
Dim objDoc
Dim objMark
Dim mybklist
Dim counter
Sub cmdPrint_Click()
Item.Save
Set objWord = CreateObject("Word.Application")
' Put the name of the Word template that contains the bookmarks
strTemplate = "form.dot"
' Location of Word template; could be on a shared LAN
strTemplate = "\\server\folder\" & strTemplate
Set objDoc = objWord.Documents.Add(strTemplate)
Set mybklist = objDoc.Bookmarks
For counter = 1 to mybklist.count
Set objMark = objDoc.Bookmarks(counter)
strField = objMark.Name
If strField = "SentField" then
strField1 = CStr(Item.SentOn)
If strField = "ElectWork" then
ObjMark("ElectWork").CheckBox.Value = True
ElseIf strField = "Furniture" then
ObjMark("Furniture").CheckBox.Value = True
ElseIf strField = "GenConstruction" then
ObjMark("GenConstruction").CheckBox.Value = True
ElseIf strField = "Other" then
ObjMark("Other").CheckBox.Value = True
ElseIf strField = "PartitionRecon" then
ObjMark("PartitionRecon").CheckBox.Value = True
ElseIf strField = "PersonnelMove" then
ObjMark("PersonnelMove").CheckBox.Value = True
ElseIf strField = "Telecomm" then
ObjMark("Telecomm").CheckBox.Value = True
End If
Else
strField1 = Item.UserProperties(strField)
End If
objMark.Range.InsertBefore strField1
'stop
Next
msgbox "Printing to " & objWord.ActivePrinter
objDoc.PrintOut 0
objWord.Quit(0)
' Clean up
Set objDoc = Nothing
Set objWord = Nothing
End Sub