Upgrade from 2003 to 2007

J

JP Ronse

Hi All,

I just made the upgrade from Office 2003 to 2007 and, oh thanks to Bill, a
lot of VBA-code is not working anymore.

Let me first explain the context, I have an Exvel workbook containing all
teammembers with their daily schedule (they are working 24/24 -7/7). I build
some code in Excel to create tasks or meetingrequests to assign tasks to my
team.

The purpose of the meetingrequests is not that I want to see them but to
inform them that they have a special task to do or to follow up. Therefore,
I don't want to see it in my calendar. So, I created a second calendar and
move the appointment to this one, using the code below.

Since the upgrade, it is still working, but I can't send the meetingrequest
anymore. Any help will be very appreciated.

With kind regards,

JP




Public WithEvents myAppointments As Outlook.Items

Private Sub Application_Startup()
Set myAppointments =
Outlook.Session.GetDefaultFolder(olFolderCalendar).Items
End Sub

Private Sub myAppointments_ItemAdd(ByVal Item As Object)
Dim MyItem As AppointmentItem
Dim blnPlanning As Boolean
Dim strSubject As String
Dim intRecipients As Integer
Dim varEntryID As Variant
Dim fldPlanningCalendar As Outlook.MAPIFolder
Dim MyPlanningItem As String

'''Stop
strSubject = "*Resource Reservation*"
'''blnPlanning = False

Set MyItem = Item
MyItem.Recipients.ResolveAll
On Error GoTo Error_myPlanningAppointments

Set fldPlanningCalendar = Outlook.Session.Folders("Mailbox - Degroote
Jean-Pierre (TEB/MST)").Folders("Planning Calendar")

''' Planning Calendar exist
''' check item
If MyItem.Subject Like strSubject Then
blnPlanning = True
Else
blnPlanning = False
End If
'''MyItem.BusyStatus = olBusy

'''blnPlanning = True ''' means that meeting can be moved to planning
calendar
For intRecipients = 1 To MyItem.Recipients.Count
If MyItem.Recipients(intRecipients) Like "Jean-Pierre Degroote" Or
MyItem.Recipients(intRecipients) Like "Degroote Jean-Pierre*" Or
MyItem.Recipients(intRecipients) Like "DEGROOTE Jean-Pierre*" Then
blnPlanning = False
Exit For
End If
Next intRecipients

If MyItem.Recipients.Count = 0 Then blnPlanning = False
If blnPlanning = True Then
With MyItem
''''.ReminderSet = False
.ResponseRequested = False
.Move fldPlanningCalendar
.Close olDiscard
End With
End If

If blnPlanning = True Then
Set MyItem = fldPlanningCalendar.Items.GetLast
MyItem.Display
End If

Exit_myPlanningAppointments:

On Error GoTo 0
Exit Sub

Error_myPlanningAppointments:
Select Case Err.Number
Case -2147221233
If MyItem.Subject Like strSubject Then
'''For intRecipients = 1 To MyItem.Recipients.Count
''' If MyItem.Organizer =
MyItem.Recipients(intRecipients) Then
''' MyItem.BusyStatus = olBusy
''' Exit For
''' Else
''' MyItem.BusyStatus = olFree
''' Exit For
''' End If
'''Next intRecipients
blnPlanning = True
If blnPlanning = True Then
MyItem.BusyStatus = olFree
End If
End If
'''MyItem.Display
Set MyItem = Nothing
Resume Exit_myPlanningAppointments:
Case Else
MsgBox prompt:="An error occured.", Title:="Warning",
Buttons:=vbOKOnly
Resume Exit_myPlanningAppointments
End Select
End Sub
 
J

JP Ronse

Hi Michael,

I got the error that the item was deleted (after the .move instruction), the
test of this evening doesn't show this error anymore??? (During the weekend
I was testing on-line, now off-line, perhaps this can make a difference?)

The issue that I still have, is that the planning calendar has a copy of the
original and that I do not longer have the possibility to send the meeting
request. I have really to send out the requests so that the involved
employees are aware of it. But there is no need to keep all these requests
in my calendar. Therefore, the checks to decide to keep it or to move it.

I cannot use .send because I must be able to edit the message or add
additional info before sending.

In Outlook 2003, the code below allowed to send the meeting request.

Does the .move insruction has now extra parameters to indicate a copy or a
move?

With kind regards,

JP
 
M

Michael Bauer [MVP - Outlook]

It's hard for me to follow what your question is. However, as to your code:
Assuming the item is open, I'd first close and then move it. The Move
function returns the moved item, so there's no need to work with the GetLast
function.

If the moved item isn't displayed, the should be an error. Your error
handler is quite meaningless for the Else case. I'd add Err.Description to
the prompt, so that you know which error occurs.

--
Best regards
Michael Bauer - MVP Outlook
Manage and share your categories:
<http://www.vboffice.net/product.html?lang=en>


Am Mon, 8 Mar 2010 19:59:57 +0100 schrieb JP Ronse:
 
J

JP Ronse

Hi Michael,

My problem is with the following code lines:

Creating a meeting request fires the ItemAdd event

If blnPlanning = True Then
With MyItem
''''.ReminderSet = False
.ResponseRequested = False
.Move fldPlanningCalendar
.Close olDiscard
End With
End If

If blnPlanning = True Then
Set MyItem = fldPlanningCalendar.Items.GetLast
MyItem.Display
End If

With blnPlanning I find out if I want to keep this meeting request in my own
calendar or not. What was working in Outlook 2003 is moving the item to the
other calendar but because I still had to send it, it recalled it form the
other calendar with .GetLast.

In outlook 2007, the moved item is a copy of the original and so I cannot
send it anymore to the recipients.

A workaround could be sending and closing the item first and move it them as
you suggest.

Is there an ItemClose event and is it fired by sending the request?

Many, many thanks for your time and assistance.

With kind regards,

JP
 
M

Michael Bauer [MVP - Outlook]

You can see all of the available events in the object browser (f2), there's
also a Close event. But as I see it, you don't need that. Please try my
suggestion:

myitem.close oldiscard
DoEvents
set myitem=myitem.move(whereever)
myitem.display

If the item doesn't get displayed, there must be an error, which you have to
catch in your error handler.

--
Best regards
Michael Bauer - MVP Outlook
Manage and share your categories:
<http://www.vboffice.net/product.html?lang=en>


Am Tue, 9 Mar 2010 20:10:28 +0100 schrieb JP Ronse:
 
J

JP Ronse

Hi Michael,

Thanks for your input, I'll try your suggestion this weekend and keep you
posted about the result.

With kind regards,

JP
 
J

JP Ronse

Hi Michael,

It is not working like I want and I don't get it fixed.

The behaviour of Outlook 2007 differs from 2003. When dragging an
appointment to another calendar, Outlook 2007 makes a copy of the
appointment and keeps the original in the calendar. Furthermore it is not
possible to send the copy.


Witk kind regards,

JP
 
J

JP Ronse

Hi Michael,

No, I dragged with the left mouse button, trying it with the right mouse
button gives indeed the options to copy or move. The "move" is then
correctly executed.


So the question remains why .move creates a copy instead of doing the move?

Should I close the item before using .move?

With kind regards,

J¨P
 
J

JP Ronse

Hi Michael,

Sorry, I've tried your suggestion but did not get the expected result.

With following code:

Public WithEvents myAppointments As Outlook.Items

Private Sub Application_Startup()
Set myAppointments =
Outlook.Session.GetDefaultFolder(olFolderCalendar).Items
End Sub


Private Sub myAppointments_ItemAdd(ByVal Item As Object)
Set fldPlanningCalendar = Outlook.Session.Folders("Mailbox - Degroote
Jean-Pierre (TEB/MST)").Folders("Planning Calendar")

Set MyItem = Item
MyItem.Close olSave
DoEvents
Set MyItem = MyItem.Move(fldPlanningCalendar)
MyItem.Display

End Sub

The meetingItem is now a copy of the original which I can't send.

Changing the code a bit (marked with ***)
Set fldPlanningCalendar = Outlook.Session.Folders("Mailbox - Degroote
Jean-Pierre (TEB/MST)").Folders("Planning Calendar")

Set MyItem = Item
MyItem.Close olSave
DoEvents
*** MyItem.Move (fldPlanningCalendar)
MyItem.Display

Gives run-time error 424, change:

MyItem.Move (fldPlanningCalendar) to MyItem.Move fldPlanningCalendar

Now the meetingItem is opened and the send button is available.

Click Send => "The operation cannot be performed because the object has been
deleted."

There are no other errors trapped.



With kind regards,

JP
 
J

JP Ronse

Hi Michael,

Finally, I could resolve the issue. It looks as Outlook 2007 moves a meeting
item as appointment item.
Following code works.

strSubject = Item.Subject
Set MyItem = Item.Move(fldPlanningCalendar)
With MyItem
=> .MeetingStatus = olMeeting ''' regenerate a meetig item
.Subject = strSubject ''' to remove 'Copy' in subject
.Display
End With

With kind regards and again thanks for your assistance,

JP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top