J
Jason Stroup
I am trying to print an Outlook Form from the form itself using a
print button. The form is a vacation day approved form, and the code
behind the button looks like the code below. It works fine as long as
the text strings are short, but the last three strings - conflicts,
resolutions and comments can be longer than 255 characters. When this
happens, it prints out #VALUE! instead of the text. ANy ideas on how
to fix this?
Thanks
Function cmdPrint_Click()
Set oExcelApp = CreateObject("excel.application")
If oExcelApp Is Nothing Then
MsgBox "Couldn't start Excel."
Else
Dim oExcelApp
Dim oExcelDoc
Dim ApplicationName
' Open a new document
Set oDoc = oExcelApp.Workbooks.Open("\\Dc2-srv\SportsMEDIA
Shares\SMTShare\Adm\Holidays & Vacations\Vacation Sick Print
Form.xls")
If Item.UserProperties("RequestType") = "VACATION" Then
oDoc.worksheets("Vacation Day(s) Request Form").range("F5").Value =
" - Request for Vacation Days"
Else
oDoc.worksheets("Vacation Day(s) Request Form").range("F5").Value =
" - Request for Sick/Personal Days"
End If
oDoc.worksheets("Vacation Day(s) Request Form").range("D7").Value =
Item.UserProperties("Employee")
oDoc.worksheets("Vacation Day(s) Request Form").range("D9").Value =
Item.UserProperties("Supervisor")
oDoc.worksheets("Vacation Day(s) Request Form").range("D11").Value =
Item.UserProperties("Director")
oDoc.worksheets("Vacation Day(s) Request Form").range("L7").Value =
Item.UserProperties("StartDate")
oDoc.worksheets("Vacation Day(s) Request Form").range("L9").Value =
Item.UserProperties("EndDate")
oDoc.worksheets("Vacation Day(s) Request Form").range("L11").Value =
Item.UserProperties("DaysRequested")
oDoc.worksheets("Vacation Day(s) Request Form").range("E16").Value =
Item.UserProperties("TotalDays")
oDoc.worksheets("Vacation Day(s) Request Form").range("E18").Value =
Item.UserProperties("DaysTaken")
oDoc.worksheets("Vacation Day(s) Request Form").range("E20").Value =
Item.UserProperties("DaysRemaining")
oDoc.worksheets("Vacation Day(s) Request Form").range("L16").Value =
Item.UserProperties("TotalDays")
oDoc.worksheets("Vacation Day(s) Request Form").range("L18").Value =
Item.UserProperties("AfterDaysTaken")
oDoc.worksheets("Vacation Day(s) Request Form").range("L20").Value =
Item.UserProperties("AfterDaysRemaining")
oDoc.worksheets("Vacation Day(s) Request Form").range("D25").Value
Item.UserProperties("Conflicts")
oDoc.worksheets("Vacation Day(s) Request Form").range("D31").Value
Item.UserProperties("Resolutions")
oDoc.worksheets("Vacation Day(s) Request Form").range("D37").Value
Item.UserProperties("Comment")
' Print the Excel document
oDoc.PrintOut
' Close and don't save changes to the document
Const wdDoNotSaveChanges = 0
oDoc.Close wdDoNotSaveChanges
' Close the Excel instance
oExcelApp.Quit
' Clean up
Set oDoc = Nothing
Set oExcelApp = Nothing
End If
End Function
print button. The form is a vacation day approved form, and the code
behind the button looks like the code below. It works fine as long as
the text strings are short, but the last three strings - conflicts,
resolutions and comments can be longer than 255 characters. When this
happens, it prints out #VALUE! instead of the text. ANy ideas on how
to fix this?
Thanks
Function cmdPrint_Click()
Set oExcelApp = CreateObject("excel.application")
If oExcelApp Is Nothing Then
MsgBox "Couldn't start Excel."
Else
Dim oExcelApp
Dim oExcelDoc
Dim ApplicationName
' Open a new document
Set oDoc = oExcelApp.Workbooks.Open("\\Dc2-srv\SportsMEDIA
Shares\SMTShare\Adm\Holidays & Vacations\Vacation Sick Print
Form.xls")
If Item.UserProperties("RequestType") = "VACATION" Then
oDoc.worksheets("Vacation Day(s) Request Form").range("F5").Value =
" - Request for Vacation Days"
Else
oDoc.worksheets("Vacation Day(s) Request Form").range("F5").Value =
" - Request for Sick/Personal Days"
End If
oDoc.worksheets("Vacation Day(s) Request Form").range("D7").Value =
Item.UserProperties("Employee")
oDoc.worksheets("Vacation Day(s) Request Form").range("D9").Value =
Item.UserProperties("Supervisor")
oDoc.worksheets("Vacation Day(s) Request Form").range("D11").Value =
Item.UserProperties("Director")
oDoc.worksheets("Vacation Day(s) Request Form").range("L7").Value =
Item.UserProperties("StartDate")
oDoc.worksheets("Vacation Day(s) Request Form").range("L9").Value =
Item.UserProperties("EndDate")
oDoc.worksheets("Vacation Day(s) Request Form").range("L11").Value =
Item.UserProperties("DaysRequested")
oDoc.worksheets("Vacation Day(s) Request Form").range("E16").Value =
Item.UserProperties("TotalDays")
oDoc.worksheets("Vacation Day(s) Request Form").range("E18").Value =
Item.UserProperties("DaysTaken")
oDoc.worksheets("Vacation Day(s) Request Form").range("E20").Value =
Item.UserProperties("DaysRemaining")
oDoc.worksheets("Vacation Day(s) Request Form").range("L16").Value =
Item.UserProperties("TotalDays")
oDoc.worksheets("Vacation Day(s) Request Form").range("L18").Value =
Item.UserProperties("AfterDaysTaken")
oDoc.worksheets("Vacation Day(s) Request Form").range("L20").Value =
Item.UserProperties("AfterDaysRemaining")
oDoc.worksheets("Vacation Day(s) Request Form").range("D25").Value
Item.UserProperties("Conflicts")
oDoc.worksheets("Vacation Day(s) Request Form").range("D31").Value
Item.UserProperties("Resolutions")
oDoc.worksheets("Vacation Day(s) Request Form").range("D37").Value
Item.UserProperties("Comment")
' Print the Excel document
oDoc.PrintOut
' Close and don't save changes to the document
Const wdDoNotSaveChanges = 0
oDoc.Close wdDoNotSaveChanges
' Close the Excel instance
oExcelApp.Quit
' Clean up
Set oDoc = Nothing
Set oExcelApp = Nothing
End If
End Function