J
James
I keep on getting an error that says: Object variable or With block
variable not set (Error 91) I looked it up and can't seem to fix the
problem. Do you know of anything? The code is below that I am useing.
Go easy on me I am new to the outlook side of things.
Private Sub btnOutlook_Click()
On Error GoTo Err_btnOutlook_Click
Dim objOApp As New Outlook.Application
Dim objAppt As AppointmentItem
Dim oExp As Outlook.Explorer
Dim i As Long
Dim j As Long
Dim oItems As Outlook.Items
Dim oFilter As Outlook.Items
Dim sEventID As Object
Set oItems = objOApp.Session.GetDefaultFolder(olFolderCalendar).Items
Set oFilter = oItems.Restrict("[Subject] = '" & sEventID & "'")
Set sEventID = Me.EventID
Set objOApp = New Outlook.Application
Set objAppt = objOApp.CreateItem(olAppointmentItem)
Set oExp = objOApp.Session.GetDefaultFolder(olFolderInbox).GetExplorer
If oFilter.Count > 0 Then
'item already exists with that value
j = oFilter.Count
For i = j To 1 Step -1
Set oAppt = oFilter(i)
objAppt.Delete
Next i
Else
With objAppt
.ReminderOverrideDefault = True
.ReminderSet = True
.ReminderMinutesBeforeStart = 1440 '1 Day
.Subject = EventID
.Importance = 2 ' high
.Start = PUDate
.End = DODate
.Body = PULocation & " - " & DOLocation & " - " & Notes & " - "
& EventDescription
.MeetingStatus = 1
.ResponseRequested = False
.Save 'Comment out if you do not want message saved to your
sent items folder
.Send
MsgBox "The event has been sent."
End With
End If
Set objOApp = Nothing
Set objAppt = Nothing
Set oExp = Nothing
Set oItems = Nothing
Set oFilter = Nothing
Set sEventID = Nothing
Exit_btnOutlook_Click:
Exit Sub
Err_btnOutlook_Click:
MsgBox Err.Description
Resume Exit_btnOutlook_Click
End Sub
Re: Finding an Outlook entry.
From: James Simmons
Thank you for answering my question. I had this posted in many other
newsgroups but no reply. I will try this and if I have anymore problems
I will post another thread.
Re: Finding an Outlook entry.
From: Ken Slovak - [MVP - Outlook]
Date Posted: 7/17/2003 3:17:00 PM
Please post some of the preceding message thread when you use that
horrid DevelopersDex interface, it doesn't do that and it makes it
very hard to follow threads. Thanks.
An If statement forms a block, all the code after If <condition> Then
to the End If is executed if <condition> is True.
In this case if you find an item and you want to delete it get the
item and use the .Delete method on it. If you want to add a new item
use an Else clause which will be executed when the If test fails.
Dim oAppt As Outlook.AppointmentItem
Dim i As Long
Dim j As Long
If oFilter.Count > 0 Then
'item already exists with that value
j = oFilter.Count
For i = j To 1 Step -1
Set oAppt = oFilter(i)
oAppt.Delete
Next i
Else
'no item, add it, you have code for that already
End If
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Lead Author, Beginning VB 6 Application Development, Wrox Press
Attachment Options
http://www.slovaktech.com/attachmentoptions.htm
Extended Reminders
http://www.slovaktech.com/extendedreminders.htm
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
variable not set (Error 91) I looked it up and can't seem to fix the
problem. Do you know of anything? The code is below that I am useing.
Go easy on me I am new to the outlook side of things.
Private Sub btnOutlook_Click()
On Error GoTo Err_btnOutlook_Click
Dim objOApp As New Outlook.Application
Dim objAppt As AppointmentItem
Dim oExp As Outlook.Explorer
Dim i As Long
Dim j As Long
Dim oItems As Outlook.Items
Dim oFilter As Outlook.Items
Dim sEventID As Object
Set oItems = objOApp.Session.GetDefaultFolder(olFolderCalendar).Items
Set oFilter = oItems.Restrict("[Subject] = '" & sEventID & "'")
Set sEventID = Me.EventID
Set objOApp = New Outlook.Application
Set objAppt = objOApp.CreateItem(olAppointmentItem)
Set oExp = objOApp.Session.GetDefaultFolder(olFolderInbox).GetExplorer
If oFilter.Count > 0 Then
'item already exists with that value
j = oFilter.Count
For i = j To 1 Step -1
Set oAppt = oFilter(i)
objAppt.Delete
Next i
Else
With objAppt
.ReminderOverrideDefault = True
.ReminderSet = True
.ReminderMinutesBeforeStart = 1440 '1 Day
.Subject = EventID
.Importance = 2 ' high
.Start = PUDate
.End = DODate
.Body = PULocation & " - " & DOLocation & " - " & Notes & " - "
& EventDescription
.MeetingStatus = 1
.ResponseRequested = False
.Save 'Comment out if you do not want message saved to your
sent items folder
.Send
MsgBox "The event has been sent."
End With
End If
Set objOApp = Nothing
Set objAppt = Nothing
Set oExp = Nothing
Set oItems = Nothing
Set oFilter = Nothing
Set sEventID = Nothing
Exit_btnOutlook_Click:
Exit Sub
Err_btnOutlook_Click:
MsgBox Err.Description
Resume Exit_btnOutlook_Click
End Sub
Re: Finding an Outlook entry.
From: James Simmons
Thank you for answering my question. I had this posted in many other
newsgroups but no reply. I will try this and if I have anymore problems
I will post another thread.
Re: Finding an Outlook entry.
From: Ken Slovak - [MVP - Outlook]
Date Posted: 7/17/2003 3:17:00 PM
Please post some of the preceding message thread when you use that
horrid DevelopersDex interface, it doesn't do that and it makes it
very hard to follow threads. Thanks.
An If statement forms a block, all the code after If <condition> Then
to the End If is executed if <condition> is True.
In this case if you find an item and you want to delete it get the
item and use the .Delete method on it. If you want to add a new item
use an Else clause which will be executed when the If test fails.
Dim oAppt As Outlook.AppointmentItem
Dim i As Long
Dim j As Long
If oFilter.Count > 0 Then
'item already exists with that value
j = oFilter.Count
For i = j To 1 Step -1
Set oAppt = oFilter(i)
oAppt.Delete
Next i
Else
'no item, add it, you have code for that already
End If
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Lead Author, Beginning VB 6 Application Development, Wrox Press
Attachment Options
http://www.slovaktech.com/attachmentoptions.htm
Extended Reminders
http://www.slovaktech.com/extendedreminders.htm
James Simmons said:After I collect the one I am trying to then what do I do. Do I use the
If statement on that and then at the end use the Then statement and then
put the code to delete the record and add the new one?
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!