Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming Forms / January 2004

Tip: Looking for answers? Try searching our database.

Item.SentOn value

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tony - 20 Jan 2004 16:36 GMT
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
Patricia Cardoza - [MVP Outlook] - 20 Jan 2004 16:45 GMT
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.

Signature

Patricia Cardoza
Outlook MVP
www.cardozasolutions.com

Author, Special Edition Using Microsoft Outlook 2003

***Please post all replies to the newsgroups***

> Can anyone tell me why I keep getting this error message when I am
> trying to get the value of Item.SentOn
[quoted text clipped - 131 lines]
>    Set MyPage = Nothing
> End Function
Tony - 26 Jan 2004 17:20 GMT
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.

> 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.
Sue Mosher [MVP] - 30 Jan 2004 01:54 GMT
What are MyPage and MyPage.Mgr? Which statement triggers the error message?
Signature

Sue Mosher, Outlook MVP
Author of
    Microsoft Outlook Programming - Jumpstart for
    Administrators, Power Users, and Developers
    http://www.outlookcode.com/jumpstart.aspx

> 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
[quoted text clipped - 23 lines]
>    objWord.Selection.TypeText Cstr(Mgr)
>    Set Mgr = Nothing
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.