Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Feb 2004
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Setting control values (OL2002/SP2)

    Newbie here again. I have some test code that does essentially what I need. However, when I run it, it has a runtime error and does not complete. There are 408 contacts in the subject folder, and many (most?) were processed. Not sure where the error occurred.

    Here's the code. Any idea why it puked or any comments on any of the code?

    Thanks!

    Sub ScheduleNextMailing()
    Dim objNS As NameSpace
    Dim itmsContacts As Items
    Dim olTempItem As ContactItem
    Dim objMktgPage As Object
    Dim lCountOfFound As Long, lItems As Long

    Set objNS = Application.GetNamespace("MAPI")
    Set itmsContacts = objNS.Folders.Item("Personal Folders"). _
    Folders.Item("Contacts"). _
    Folders.Item("CCS Contacts"). _
    Items


    ' Loop through journal folder items
    For lItems = itmsContacts.Count To 1 Step -1
    Set olTempItem = itmsContacts(lItems)
    Set objMktgPage = olTempItem.GetInspector.ModifiedFormPages("Marketi ng")
    objMktgPage.Controls("txtNextPostcard").Value = "TEST"

    Next lItems

    ' empty objects
    Set itmsContacts = Nothing
    Set objNS = Nothing
    End Sub

  2. #2
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Salt Lake City, Utah, USA
    Posts
    9,508
    Thanks
    0
    Thanked 6 Times in 6 Posts

    Re: Setting control values (OL2002/SP2)

    <P ID="edit" class=small>(Edited by JohnBF on 04-Mar-04 19:09. On further thought ...)</P>Scott, as written I'm guessing (from unkind experience) that your code may puke on the ".ModifiedFormPages" Property if it hits a Distribution List item; as DL is not a ContactItem, it's a DistListItem. In the appropriate part of your code try something like (untested):

    For lItems = itmsContacts.Count To 1 Step -1
    If itmsContacts(lItems).Class = olContact Then
    Set olTempItem = itmsContacts(lItems)
    Set objMktgPage = olTempItem.GetInspector.ModifiedFormPages("Marketi ng")
    objMktgPage.Controls("txtNextPostcard").Value = "TEST"
    End If

    EDIT. I may be a bit off track; I guess any item which doesn't have '.ModifiedFormPages("Marketing")' would cause the code to error, so perhaps this would be better:

    For lItems = itmsContacts.Count To 1 Step -1
    On Error Resume next
    Set objMktgPage = itmsContacts(lItems).GetInspector.ModifiedFormPage s("Marketing")
    On Error Goto 0
    If Not objMktgPage Is Nothing Then _
    objMktgPage.Controls("txtNextPostcard").Value = "TEST"
    -John ... I float in liquid gardens
    UTC -7ąDS

  3. #3
    New Lounger
    Join Date
    Feb 2004
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Setting control values (OL2002/SP2)

    Thanks John. I'll have to read your code a few more times to process it, but I appreciate the help!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •