Newbie with runtime error

  • Thread starter Thread starter Scott Smith
  • Start date Start date
S

Scott Smith

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("Marketing")
objMktgPage.Controls("txtNextPostcard").Value = "TEST"

Next lItems

' empty objects
Set itmsContacts = Nothing
Set objNS = Nothing
End Sub
 
What is it you're trying to do? Your code just loops through all the items,
making a change to a control and then moves on to the next item. You're not
doing anything to make a persistent change to the items.
 
I'm just doing one step at a time to isolate errors as I'm learning.

In the end, rather setting the control to "TEST", I'll be setting it to
a date value calculated by adding the following: date of most recent
mailing (calculated by searching journal entries) and number of days
between mailings (value set per contact in custom form)

Does this make sense?
 
No, it doesn't make sense, for these reasons:

-- Changes to UI are not persistent.
-- Your code doesn't save the item that's being changed. Use the Save
method.

If you want to change the item, you should change a property -- not a
control -- and save the item. See
http://www.outlookcode.com/d/propsyntax.htm for property syntax basics.

Also note: The newsgroup interface you are using apparently does not quote
earlier messages in the thread, making your latest message so short on
detail that you risk not getting the answer you're looking for. Please take
the time to quote the original message.
 
Thanks for your help Sue. (Sorry for the delay)
Your post sent me in the correct direction. (Which ultimately was to
the bookstore to get your book!)
 
Back
Top