D
David M
We have upgraded our clients to Office 2003. A form they used in Outlook 2000
will no longer print as seen on the screen, instead it just prints a list of
data. In Outlook 2000 we had the XPrint ActiveX Control and Outlook
Extension. As far as I can tell there is no similar product for Outlook 2003.
We tried to use the same AddIn and it will print the form as seen, but it
will also crash Outlook when you try to print something else. I need a way to
print forms as seen on the screen.
I think we could edit the form to include a VBS script to print to work, but
I am not 100% sure how to do that. I have the VBS script i created at the
bottom of this.
When i try to use this VBS script on a button in the form, nothing happens.
I am sure i am jacking the script up.
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("C:\MyForm1.dot")
strMyField = Item.UserProperties.Find("From")
oDoc.FormFields("From").Result = strMyField
strMyField = Item.UserProperties.Find("Sent")
oDoc.FormFields("Sent").Result = strMyField
strMyField = Item.UserProperties.Find("To")
oDoc.FormFields("To").Result = strMyField
strMyField = Item.UserProperties.Find("Subject")
oDoc.FormFields("Subject").Result = strMyField
strMyField = Item.UserProperties.Find("Add")
oDoc.FormFields("Add").Result = strMyField
strMyField = Item.UserProperties.Find("Blount")
oDoc.FormFields("Blount").Result = strMyField
strMyField = Item.UserProperties.Find("ClientName")
oDoc.FormFields("Client Name").Result = strMyField
strMyField = Item.UserProperties.Find("ClientNo")
oDoc.FormFields("Client No:").Result = strMyField
strMyField = Item.UserProperties.Find("Columbia")
oDoc.FormFields("Columbia").Result = strMyField
strMyField = Item.UserProperties.Find("Cookeville")
oDoc.FormFields("Cookeville").Result = strMyField
strMyField = Item.UserProperties.Find("Date")
oDoc.FormFields("Date").Result = strMyField
strMyField = Item.UserProperties.Find("Ends")
oDoc.FormFields("Ends").Result = strMyField
strMyField = Item.UserProperties.Find("Hopkinsville")
oDoc.FormFields("Hopkinsville").Result = strMyField
strMyField = Item.UserProperties.Find("Lebanon")
oDoc.FormFields("Lebanon").Result = strMyField
strMyField = Item.UserProperties.Find("Manchester")
oDoc.FormFields("Manchester").Result = strMyField
strMyField = Item.UserProperties.Find("Middlesboro")
oDoc.FormFields("Middlesboro").Result = strMyField
strMyField = Item.UserProperties.Find("Morristown")
oDoc.FormFields("Morristown").Result = strMyField
strMyField = Item.UserProperties.Find("OtherCheck")
oDoc.FormFields("Other check").Result = strMyField
strMyField = Item.UserProperties.Find("PhoneNo")
oDoc.FormFields("Phone No:").Result = strMyField
strMyField = Item.UserProperties.Find("Pineville")
oDoc.FormFields("Pineville").Result = strMyField
strMyField = Item.UserProperties.Find("Replace")
oDoc.FormFields("Replace").Result = strMyField
strMyField = Item.UserProperties.Find("RequestedBy")
oDoc.FormFields("Requested By:").Result = strMyField
strMyField = Item.UserProperties.Find("Rotation1")
oDoc.FormFields("Rotation").Result = strMyField
strMyField = Item.UserProperties.Find("Sevier")
oDoc.FormFields("Sevier").Result = strMyField
strMyField = Item.UserProperties.Find("Starts")
oDoc.FormFields("Starts").Result = strMyField
strMyField = Item.UserProperties.Find("Tazewell")
oDoc.FormFields("Tazewell").Result = strMyField
strMyField = Item.UserProperties.Find("WKnox")
oDoc.FormFields("W.Knox").Result = strMyField
' If the form contains user-defined fields, you can use
' the following syntax to transfer the contents of a
' user-defined field (FieldName) to Word:
' strMyField = Item.UserProperties.Find("FieldName")
' oDoc.FormFields("Text3").Result = strMyField
' 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
' Restore previous setting
oWordApp.Options.PrintBackground = bolPrintBackground
' Close and don't save changes to the document
Const wdDoNotSaveChanges = 0
oDoc.Close wdDoNotSaveChanges
' Close the Word instance
oWordApp.Quit
' Clean up
Set oDoc = Nothing
Set oWordApp = Nothing
End If
End Sub
So if possible could someone point me to a solution i could use to print
forms as seen through outlook or point me in the direction of some kind of
guide to create a VBS script to allow me to push out to work from a form in
outlook? Any help at all would be great. Thank You.
will no longer print as seen on the screen, instead it just prints a list of
data. In Outlook 2000 we had the XPrint ActiveX Control and Outlook
Extension. As far as I can tell there is no similar product for Outlook 2003.
We tried to use the same AddIn and it will print the form as seen, but it
will also crash Outlook when you try to print something else. I need a way to
print forms as seen on the screen.
I think we could edit the form to include a VBS script to print to work, but
I am not 100% sure how to do that. I have the VBS script i created at the
bottom of this.
When i try to use this VBS script on a button in the form, nothing happens.
I am sure i am jacking the script up.
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("C:\MyForm1.dot")
strMyField = Item.UserProperties.Find("From")
oDoc.FormFields("From").Result = strMyField
strMyField = Item.UserProperties.Find("Sent")
oDoc.FormFields("Sent").Result = strMyField
strMyField = Item.UserProperties.Find("To")
oDoc.FormFields("To").Result = strMyField
strMyField = Item.UserProperties.Find("Subject")
oDoc.FormFields("Subject").Result = strMyField
strMyField = Item.UserProperties.Find("Add")
oDoc.FormFields("Add").Result = strMyField
strMyField = Item.UserProperties.Find("Blount")
oDoc.FormFields("Blount").Result = strMyField
strMyField = Item.UserProperties.Find("ClientName")
oDoc.FormFields("Client Name").Result = strMyField
strMyField = Item.UserProperties.Find("ClientNo")
oDoc.FormFields("Client No:").Result = strMyField
strMyField = Item.UserProperties.Find("Columbia")
oDoc.FormFields("Columbia").Result = strMyField
strMyField = Item.UserProperties.Find("Cookeville")
oDoc.FormFields("Cookeville").Result = strMyField
strMyField = Item.UserProperties.Find("Date")
oDoc.FormFields("Date").Result = strMyField
strMyField = Item.UserProperties.Find("Ends")
oDoc.FormFields("Ends").Result = strMyField
strMyField = Item.UserProperties.Find("Hopkinsville")
oDoc.FormFields("Hopkinsville").Result = strMyField
strMyField = Item.UserProperties.Find("Lebanon")
oDoc.FormFields("Lebanon").Result = strMyField
strMyField = Item.UserProperties.Find("Manchester")
oDoc.FormFields("Manchester").Result = strMyField
strMyField = Item.UserProperties.Find("Middlesboro")
oDoc.FormFields("Middlesboro").Result = strMyField
strMyField = Item.UserProperties.Find("Morristown")
oDoc.FormFields("Morristown").Result = strMyField
strMyField = Item.UserProperties.Find("OtherCheck")
oDoc.FormFields("Other check").Result = strMyField
strMyField = Item.UserProperties.Find("PhoneNo")
oDoc.FormFields("Phone No:").Result = strMyField
strMyField = Item.UserProperties.Find("Pineville")
oDoc.FormFields("Pineville").Result = strMyField
strMyField = Item.UserProperties.Find("Replace")
oDoc.FormFields("Replace").Result = strMyField
strMyField = Item.UserProperties.Find("RequestedBy")
oDoc.FormFields("Requested By:").Result = strMyField
strMyField = Item.UserProperties.Find("Rotation1")
oDoc.FormFields("Rotation").Result = strMyField
strMyField = Item.UserProperties.Find("Sevier")
oDoc.FormFields("Sevier").Result = strMyField
strMyField = Item.UserProperties.Find("Starts")
oDoc.FormFields("Starts").Result = strMyField
strMyField = Item.UserProperties.Find("Tazewell")
oDoc.FormFields("Tazewell").Result = strMyField
strMyField = Item.UserProperties.Find("WKnox")
oDoc.FormFields("W.Knox").Result = strMyField
' If the form contains user-defined fields, you can use
' the following syntax to transfer the contents of a
' user-defined field (FieldName) to Word:
' strMyField = Item.UserProperties.Find("FieldName")
' oDoc.FormFields("Text3").Result = strMyField
' 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
' Restore previous setting
oWordApp.Options.PrintBackground = bolPrintBackground
' Close and don't save changes to the document
Const wdDoNotSaveChanges = 0
oDoc.Close wdDoNotSaveChanges
' Close the Word instance
oWordApp.Quit
' Clean up
Set oDoc = Nothing
Set oWordApp = Nothing
End If
End Sub
So if possible could someone point me to a solution i could use to print
forms as seen through outlook or point me in the direction of some kind of
guide to create a VBS script to allow me to push out to work from a form in
outlook? Any help at all would be great. Thank You.