Item.SentOn value

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
 
P

Patricia Cardoza - [MVP Outlook]

I take it SentOn is a custom field? If so you need the following syntax:

Item.UserProperties.Find("SentOn").Value

You can't refer to custom fields with the Item.FieldName syntax. That's only
for standard built in fields.

--
Patricia Cardoza
Outlook MVP
www.cardozasolutions.com

Author, Special Edition Using Microsoft Outlook 2003

***Please post all replies to the newsgroups***
Tony said:
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
 
T

Tony

After I made a few changes I got it to work by doing what you said.
I thought I was using the OL Field "sent" on my form, but after
hearing you explain it, it made better since. I wanted the sent date
to show on the read page but when I called it I just wanted to grab
the senton data and send it to my word bookmark. Can this be done?

This is what I currently used and it seemed to work.
Set MailedOn = MyPage.MailedOn

Now the problem moved on down the list to another field.
This is another OL Field (The "To" filed) that is on the form but when
I tried to do it the same way I did above I am back to Square 1
("Object Does not support this property of method").

I have tried multiple variations of this, presently I am on this one.
I think it is the closest solution I have so far. All I get is either
"Object does not support this" or "Object Required".

Here is what the code looks like
Dim Mgr
objWord.ActiveDocument.Bookmarks("Mgr").Select
Set Mgr = MyPage.Mgr
If Mgr = True then
Mgr = "Yes"
ElseIf Mgr = False then
Mgr = ""
End If
objWord.Selection.TypeText Cstr(Mgr)
Set Mgr = Nothing

I tried it this way as well and got the same message.
Dim Mgr
objWord.ActiveDocument.Bookmarks("Mgr").Select
Set Mgr = MyPage.Mgr
objWord.Selection.TypeText Cstr(Mgr)
Set Mgr = Nothing

Any Suggestions

Thanks.
 
S

Sue Mosher [MVP]

What are MyPage and MyPage.Mgr? Which statement triggers the error message?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top