T
Tony
Can anyone tell me why I keep getting this error message when I am
trying to get the value of Item.SentOn
Object Required: '[string: "John Smith"]'
I am using OL2000 and my button takes the data from my form and
constructs a word document placing the data from each field to a
Bookmark location on the Word Document.
In dire need of some assistance.
Thanks
My code looks something like this.
Option Explicit
'Printing function
' - opening a Word template with bookmarks
' - read bookmarks list from template and match with the field names
in Outlook form
' - value in form is that populated to the Word doc for printing
Dim strTemplate
Dim objWord
Dim objDocs
Dim mybklist
Dim MyPage,EmpName
Function Item_Open()
Set MyPage = Item.GetInspector.ModifiedFormPages("Vacation
Request")
End Function
Sub cmdBookmarks_Click
Set objWord = CreateObject("Word.Application")
' Put the name of your Word template that contains the bookmarks
strTemplate = "VacReq.dot"
' Location of Word template; could be on a shared LAN
strTemplate = "\\Public Folder\Public2\Templates\" & strTemplate
Set objDocs = objWord.Documents
objDocs.Add strTemplate
set mybklist = objWord.ActiveDocument.Bookmarks
' THIS PART DOESN'T WORK
'Bookmark SentDate
Dim SentDate
objWord.ActiveDocument.Bookmarks("SentDate").Select
'It seems to crash on the next statement
Set SentDate = MyPage.SentOn
If SentDate = True then
SentDate = SentDate
ElseIf SentDate = False then
SentDate = "HAS NOT BEEN MAILED"
End If
objWord.Selection.TypeText Cstr(SentDate)
Set SentDate = Nothing
' THIS WORKS JUST FINE
'Bookmark EmpName
Dim EmpName
objWord.ActiveDocument.Bookmarks("EmpName").Select
Set EmpName = MyPage.EmpName
If EmpName = True then
EmpName = "Yes"
ElseIf EmpName = False then
EmpName = ""
End If
objWord.Selection.TypeText Cstr(EmpName)
Set EmpName = Nothing
' THIS WORKS JUST FINE
'Bookmark Body
Dim Body
objWord.ActiveDocument.Bookmarks("Body").Select
Set Body = Item.Body
If Body = True then
Body = "Yes"
ElseIf Body = False then
Body = ""
End If
objWord.Selection.TypeText Cstr(Body)
Set Body = Nothing
objWord.visible = True
Set ObjDocs = Nothing
Set mybklist = Nothing
Set objWord = Nothing
End Sub
Function Item_Write()
Item.Subject = MyPage.EmpName & " is needing some time off."
End Function
Function Item_CustomAction(ByVal Action, ByVal NewItem)
Select Case Action.Name
Case "Approve"
MyPage.Approval = "Approved"
NewItem.cc = MyPage.EmpName
Call ActionData
Case "Deny"
MyPage.Approval = "Denied"
Call ActionData
Case "Reply"
Call ActionData
Case "ReplyToAll"
Call ActionData
Case "Forward"
Call ActionData
Case Else
End Select
End Function
Sub ActionData()
' I HAVE EVEN TRIED USING THIS TYPE OF CALL FOR THE VALUE BUT ALL I
GET IS "THIS OBJECT DOESN'T SUPPORT THAT PROPERTY"
NewItem.UserProperties.find("SentDate").Value =
Item.UserProperties.find("SentDate").Value
NewItem.UserProperties.find("EmpName").Value =
Item.UserProperties.find("EmpName").Value
End Sub
Function Item_Close()
Set MyPage = Nothing
End Function
trying to get the value of Item.SentOn
Object Required: '[string: "John Smith"]'
I am using OL2000 and my button takes the data from my form and
constructs a word document placing the data from each field to a
Bookmark location on the Word Document.
In dire need of some assistance.
Thanks
My code looks something like this.
Option Explicit
'Printing function
' - opening a Word template with bookmarks
' - read bookmarks list from template and match with the field names
in Outlook form
' - value in form is that populated to the Word doc for printing
Dim strTemplate
Dim objWord
Dim objDocs
Dim mybklist
Dim MyPage,EmpName
Function Item_Open()
Set MyPage = Item.GetInspector.ModifiedFormPages("Vacation
Request")
End Function
Sub cmdBookmarks_Click
Set objWord = CreateObject("Word.Application")
' Put the name of your Word template that contains the bookmarks
strTemplate = "VacReq.dot"
' Location of Word template; could be on a shared LAN
strTemplate = "\\Public Folder\Public2\Templates\" & strTemplate
Set objDocs = objWord.Documents
objDocs.Add strTemplate
set mybklist = objWord.ActiveDocument.Bookmarks
' THIS PART DOESN'T WORK
'Bookmark SentDate
Dim SentDate
objWord.ActiveDocument.Bookmarks("SentDate").Select
'It seems to crash on the next statement
Set SentDate = MyPage.SentOn
If SentDate = True then
SentDate = SentDate
ElseIf SentDate = False then
SentDate = "HAS NOT BEEN MAILED"
End If
objWord.Selection.TypeText Cstr(SentDate)
Set SentDate = Nothing
' THIS WORKS JUST FINE
'Bookmark EmpName
Dim EmpName
objWord.ActiveDocument.Bookmarks("EmpName").Select
Set EmpName = MyPage.EmpName
If EmpName = True then
EmpName = "Yes"
ElseIf EmpName = False then
EmpName = ""
End If
objWord.Selection.TypeText Cstr(EmpName)
Set EmpName = Nothing
' THIS WORKS JUST FINE
'Bookmark Body
Dim Body
objWord.ActiveDocument.Bookmarks("Body").Select
Set Body = Item.Body
If Body = True then
Body = "Yes"
ElseIf Body = False then
Body = ""
End If
objWord.Selection.TypeText Cstr(Body)
Set Body = Nothing
objWord.visible = True
Set ObjDocs = Nothing
Set mybklist = Nothing
Set objWord = Nothing
End Sub
Function Item_Write()
Item.Subject = MyPage.EmpName & " is needing some time off."
End Function
Function Item_CustomAction(ByVal Action, ByVal NewItem)
Select Case Action.Name
Case "Approve"
MyPage.Approval = "Approved"
NewItem.cc = MyPage.EmpName
Call ActionData
Case "Deny"
MyPage.Approval = "Denied"
Call ActionData
Case "Reply"
Call ActionData
Case "ReplyToAll"
Call ActionData
Case "Forward"
Call ActionData
Case Else
End Select
End Function
Sub ActionData()
' I HAVE EVEN TRIED USING THIS TYPE OF CALL FOR THE VALUE BUT ALL I
GET IS "THIS OBJECT DOESN'T SUPPORT THAT PROPERTY"
NewItem.UserProperties.find("SentDate").Value =
Item.UserProperties.find("SentDate").Value
NewItem.UserProperties.find("EmpName").Value =
Item.UserProperties.find("EmpName").Value
End Sub
Function Item_Close()
Set MyPage = Nothing
End Function