Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem deleting outlook appointments 1

Status
Not open for further replies.

PBURNHAM

Programmer
Jun 5, 2001
5
0
0
US
Our Help Desk asked me to give them their hardware checkout application the ability to automatically send appointments to the help desk outlook calendar for hardware setups. This I was able to do, however the delete aborts with a runtime error 91 "Object or with block variable not set".

For our user systems, I have to select the Outlook98 object module for the compile. On my system, I have the Outlook9 (2000)object module. The delete works with the later object module, not with the earlier one. The difference is that the developers have the Office SR-1 release and the users do not. I'm told there are several reasons why we haven't upgraded all systems to SR-1. Is there a way to delete an appointment using the Outlook98 object module? It creates appointments just fine. I just can't delete them. -Thanks
 
Am about to start work on a function that will add items to the calandar. Could I get the code from you on how to do this or do you know of a web site that has instructions?
 
Found Some good examples on Microsoft on the subject.
In your code can you specify specific calendar (shared) or the appointment to be assigned to
 
Here is the routine that I use to create a calendar event. For setup purposes, we create both a setup and takedown calendar message.

Sub make_appt()

Dim olApp As Outlook.Application
Dim olappt As Outlook.AppointmentItem
Dim olNameSpace As Outlook.NameSpace
Dim olRecipient As Outlook.Recipient
Dim SendTo As String
Dim mystart As String
Dim myend As String
Dim mySQL As String
Dim tmpID As String
Dim NewID As Long

mystart = txtSetup(1).Text & Space(1) & cboSetup(0).Text & Space(1) & lstSetup(0).Text
myend = DateAdd("n", 15, mystart)

Set olApp = New Outlook.Application
Set olNameSpace = olApp.GetNamespace("MAPI")

'Name of the recipient as entered for email

Set olRecipient = olNameSpace.CreateRecipient("Help Center (IMB Computer)")
' Set olRecipient = olNameSpace.CreateRecipient("Burnham, Paul")
Set olappt = olNameSpace.GetSharedDefaultFolder(olRecipient, olFolderCalendar).Items.Add

With olappt
'Create the setup appointment
.Location = txtSetup(0).Text
.Subject = "Hardware setup"
.Body = txtSetup(3).Text
.Start = CDate(mystart)
.End = CDate(myend)
.ReminderMinutesBeforeStart = 15
.Save
End With

'The appointment has been set, but we need to create an appointment record to give us the
'the information to delete the correct record if a setup appointment is cancelled

tmpID = Trim(olappt.EntryID)
NewID = Next_ID("NEXT_APPT")
mySQL = "insert CalendarAppt(Recnum, EntryID, ApptRecipient, DateTimeStart, DateTimeEnd, ApptSubject, CheckoutID, Voided)" & _
" Values(" & NewID & ", '" & tmpID & "', '" & SendTo & "', '" & LTrim(mystart) & "', '" & LTrim(myend) & "', 'Hardware Setup', " & HcoForm.lblLIST.Caption & ", 0)"
' " Values(" & NewID & ", '" & SendTo & "', '" & LTrim(mystart) & "', '" & LTrim(myend) & "', 'Hardware Setup', " & HcoForm.lblLIST.Caption & ", 0)"
gvEXE_DB.Execute mySQL

mystart = ""
myend = ""
Set olappt = Nothing
Set olNameSpace = Nothing
Set olApp = Nothing
Set olRecipient = Nothing

mystart = txtSetup(2).Text & Space(1) & cboSetup(1).Text & Space(1) & lstSetup(1).Text
myend = DateAdd("n", 15, mystart)

'Now for the takedown entry

Set olApp = New Outlook.Application
Set olNameSpace = olApp.GetNamespace("MAPI")

' Set olRecipient = olNameSpace.CreateRecipient("Burnham, Paul")
Set olRecipient = olNameSpace.CreateRecipient("Help Center (IMB Computer)")
Set olappt = olNameSpace.GetSharedDefaultFolder(olRecipient, olFolderCalendar).Items.Add

With olappt
'Create the setup appointment
.Location = txtSetup(0).Text
.Subject = "Hardware Takedown"
.Start = CDate(mystart)
.End = CDate(myend)
.ReminderMinutesBeforeStart = 15
.Save
End With

'Here we are creating the takedown appointment record.

tmpID = Trim(olappt.EntryID)
NewID = Next_ID("NEXT_APPT")
mySQL = "insert CalendarAppt(Recnum, EntryID, ApptRecipient, DateTimeStart, DateTimeEnd, ApptSubject, CheckoutID, Voided)" & _
" Values(" & NewID & ", '" & tmpID & "', '" & SendTo & "', '" & LTrim(mystart) & "', '" & LTrim(myend) & "', 'Hardware Takedown', " & HcoForm.lblLIST.Caption & ", 0)"
gvEXE_DB.Execute mySQL

'Release the Outlook object variable

Set olappt = Nothing
Set olNameSpace = Nothing
Set olApp = Nothing
Set olRecipient = Nothing

HcoForm.lbldat(0).Caption = txtSetup(1).Text
HcoForm.lbldat(1).Caption = txtSetup(2).Text

End Sub
 
I want to create a VB program that is similar to New Appointment in MS Outlook. I added a module that has a sub main. I created a form that you can see at:
For the Startup Object (under project properties), I can only choose either a sub main or a form.
My question is what should I choose for the startup object and how do I integrate the fields so it can function same as New Appointment in MS Outlook ?
Thanks.

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top