B
Bill Billmire
Sue,
I am still having problems getting the form I created to print. I have made
some progress (via trial and error) from where I was about two weeks ago, but
problems still exist that prevent me from calling this complete. The
original code example was published in:
(http://www.outlookexchange.com/articles/home/lengho01.asp)
Reference previous thread dated 12/9/2004, Subject: OLK2K3: Form Printing
Assistance (Standard Field).
I added some code in the loop to handle the "standard field" and the loop
now iterates completely through the entire collection of bookmarks. The
three remaining issues are:
1) The standard field (Item.SentOn) is still not being processed as I want.
(i.e., being printed on the output (page).
2) Using msgboxes I can validate that the loop processes all the bookmarks,
however, only the last bookmark gets printed on the output (page).
3) Using the code line: "objWord.PrintOut Background = True" causes the
VBScript to error out with: Microsoft VBScript runtime error: Variable is
undefined: 'Background'. Since I am using Office 2003, I am wondering if the
"Background" parameter, or it's syntax has changed in usage from previous
versions of Work/Outlook?
Latest Code...
'------------------Printing Routine--------------------
Dim objWord
Dim strTemplate
Dim objDocs
Dim objDoc
Dim objMark
Dim mybklist
Dim counter
Dim objField
Sub cmdPrint_Click()
Set objWord = CreateObject("Word.Application")
' Put the name of the Word template that contains the bookmarks
strTemplate = "OSR.dot"
' Location of Word template; could be on a shared LAN
strTemplate = "\\ivory\forms\" & strTemplate
Set objDocs = objWord.Documents
objDocs.Add strTemplate
Set mybklist = objWord.ActiveDocument.Bookmarks
For counter = 1 to mybklist.count
Dim strField
Dim strField1
Set objMark = objWord.ActiveDocument.Bookmarks(counter)
strField = objMark.Name
If strField = "SentField" then
strField = CStr(Item.SentOn)
msgbox strField 'temporary while debugging
Else
msgbox strField 'temporary while debugging
strField1 = Item.UserProperties(strField)
msgbox strField1 'temporary while debugging
Set objDoc = objDocs.Add(strTemplate)
Set objMark = objWord.ActiveDocument.Bookmarks(counter)
End If
objMark.Range.InsertAfter strField1
Next
objWord.PrintOut Background = True
objWord.Quit(0)
End Sub
Thanks for your help!
Bill Billmire -
(e-mail address removed)
I am still having problems getting the form I created to print. I have made
some progress (via trial and error) from where I was about two weeks ago, but
problems still exist that prevent me from calling this complete. The
original code example was published in:
(http://www.outlookexchange.com/articles/home/lengho01.asp)
Reference previous thread dated 12/9/2004, Subject: OLK2K3: Form Printing
Assistance (Standard Field).
I added some code in the loop to handle the "standard field" and the loop
now iterates completely through the entire collection of bookmarks. The
three remaining issues are:
1) The standard field (Item.SentOn) is still not being processed as I want.
(i.e., being printed on the output (page).
2) Using msgboxes I can validate that the loop processes all the bookmarks,
however, only the last bookmark gets printed on the output (page).
3) Using the code line: "objWord.PrintOut Background = True" causes the
VBScript to error out with: Microsoft VBScript runtime error: Variable is
undefined: 'Background'. Since I am using Office 2003, I am wondering if the
"Background" parameter, or it's syntax has changed in usage from previous
versions of Work/Outlook?
Latest Code...
'------------------Printing Routine--------------------
Dim objWord
Dim strTemplate
Dim objDocs
Dim objDoc
Dim objMark
Dim mybklist
Dim counter
Dim objField
Sub cmdPrint_Click()
Set objWord = CreateObject("Word.Application")
' Put the name of the Word template that contains the bookmarks
strTemplate = "OSR.dot"
' Location of Word template; could be on a shared LAN
strTemplate = "\\ivory\forms\" & strTemplate
Set objDocs = objWord.Documents
objDocs.Add strTemplate
Set mybklist = objWord.ActiveDocument.Bookmarks
For counter = 1 to mybklist.count
Dim strField
Dim strField1
Set objMark = objWord.ActiveDocument.Bookmarks(counter)
strField = objMark.Name
If strField = "SentField" then
strField = CStr(Item.SentOn)
msgbox strField 'temporary while debugging
Else
msgbox strField 'temporary while debugging
strField1 = Item.UserProperties(strField)
msgbox strField1 'temporary while debugging
Set objDoc = objDocs.Add(strTemplate)
Set objMark = objWord.ActiveDocument.Bookmarks(counter)
End If
objMark.Range.InsertAfter strField1
Next
objWord.PrintOut Background = True
objWord.Quit(0)
End Sub
Thanks for your help!
Bill Billmire -
(e-mail address removed)