Link to home
Create AccountLog in
Avatar of RevIngram
RevIngram

asked on

Change a meeting into an appointment

Hi Experts,
I need to change a number of meetings in an outlook calendar back into appointments, I found the code below on the web, but it does nothing under Outlook 2007, any ideas why. I'm not a programmer and have spent an evening playing but can't solve it.
Cheers,
Charlie
Sub ConvertMeetingsToAppts()
    Dim strWindowType As String
    Dim sel As Outlook.Selection
    Dim itm As Object
    
    strWindowType = TypeName(Application.ActiveWindow)
    Select Case strWindowType
        Case "Explorer"
            Set sel = Application.ActiveExplorer.Selection
            If sel.count > 0 Then
                For Each itm In sel
                    If itm.Class = olAppointment Then
                        If itm.MeetingStatus <> olNonMeeting Then
                            Call ConvertMeetingToAppt(itm)
                        End If
                    End If
                Next
            End If
        Case "Inspector"
            Set itm = Application.ActiveInspector.CurrentItem
            If itm.Class = olAppointment Then
                If itm.MeetingStatus <> olNonMeeting Then
                    Call ConvertMeetingToAppt(itm)
                End If
            End If
    End Select
    
    Set itm = Nothing
    Set sel = Nothing
End Sub
 
Sub ConvertMeetingToAppt(myMeeting As Outlook.AppointmentItem)
    With myMeeting
        ' remove all recipients
        Do Until .Recipients.count = 0
            .Recipients.Remove 1
        Loop
        ' reset meeting status
        .MeetingStatus = olNonMeeting
        .Save
    End With
End Sub

Open in new window

Avatar of Vikas Shah
Vikas Shah
Flag of India image

Notes on the code:

1. The actual work is done by the ConvertMeetingToAppt subroutine, which takes an Outlook.AppointmentItem as its sole argument.

2. The ConvertMeetingsToAppts demonstrates how to construct a macro that can run against both an Explorer (folder) window or an Inspector (item) window by checking the ActiveWindow property.

3. Calls to the Recipients collection will trigger a security prompt in Outlook VBA code in versions earlier than Outlook 2003 and 2007.

4. Put the code in any Outlook VBA code module.

5. If you might want to run in a loop than you can use a countdown loop.

6. Nothing in this code is version-specific. You can use it in the Outlook 2007
Sub ConvertMeetingsToAppts()
    Dim strWindowType As String
    Dim sel As Outlook.Selection
    Dim itm As Object
    
    strWindowType = TypeName(Application.ActiveWindow)
    Select Case strWindowType
        Case "Explorer"
            Set sel = Application.ActiveExplorer.Selection
            If sel.count > 0 Then
                For Each itm In sel
                    If itm.Class = olAppointment Then
                        If itm.MeetingStatus <> olNonMeeting Then
                            Call ConvertMeetingToAppt(itm)
                        End If
                    End If
                Next
            End If
        Case "Inspector"
            Set itm = Application.ActiveInspector.CurrentItem
            If itm.Class = olAppointment Then
                If itm.MeetingStatus <> olNonMeeting Then
                    Call ConvertMeetingToAppt(itm)
                End If
            End If
    End Select
    
    Set itm = Nothing
    Set sel = Nothing
End Sub
 
Sub ConvertMeetingToAppt(myMeeting As Outlook.AppointmentItem)
    With myMeeting
        ' remove all recipients
        Do Until .Recipients.count = 0
            .Recipients.Remove 1
        Loop
        ' reset meeting status
        .MeetingStatus = olNonMeeting
        .Save
    End With
End Sub

Open in new window

Avatar of David Lee
Hi, Charlie.

That code should work.  Does it run at all?
Avatar of RevIngram
RevIngram

ASKER

Hi BlueDevilFan and Shahvikas,
Thanks for your replies, it encouraged me to look further and see what was going on.
I didn't realise the macro ran only on selected items, I thought it worked it's way through the selected folder!.
Once I selected all the items in the folder it worked great.
Sorry to have taken up your time! Can I split the points between you?
Charlie.

P.S. while I have you in email contact, please could you recomend a good book that I could read to learn visual basic? I learned Basic on a ZX Spectrum as a kid and was quite good at it, and I learned some Macromedia Lingo at Uni for a Director CD-Rom, but I'd really like to learn VB so I can do some of this myself. Thanks Guys!
Hi RevIngram,

Programming Microsoft Visual Basic 2005 is a best book i recommend. It is published by Microsoft Press.

As far as points concern, it is complete up to you. We are here to solve the issues and gain a knowledge. It is just that those points encourage everyone to get into this with more enthusiasm. still, if you need my suggestion than i could say you should split it as it was not only me who answered. I think BlueDevilFan also deserve it.

Rest is up to you.
Hi Guys,
The Macro now runs and does what it is supposed to but it hasn't solved my problem.
There are two different "types" of appointments in our public calendar. The first group have been entered manually by clicking the create new appointment button in either outlook or OWA.
The second group were imported from an excel file.
Now here's the problem :-
If anyone (including the organizer) makes a change (in the notes) to an appointment from the second group (the imported appointments) using OWA, it turns to appointment into a meeting and prevents anyone else from making further changes.
I can run the above macro again and clear the two meeting fields, which resets the appointment, but the next time someone makes a change via OWA, once again,  it changes the appointment to a meeting.
It's driving me mad...
One solution would be to delete all the imported appointments and recreate them individually, but there are about 200 and that would take ages.
I've proved this is the problem but exporting some appointments to exel and then importing them into a fresh calendar. The problem was easily replicated.
Is there another field I should be changing to prevent this happening?
Any suggestions?
Cheers,
Charlie
As far as my knowledge goes, this is by default behavior set in the Outlook 2007.

As per the common Calendar terminology of Outlook 2007 by microsoft is:

1.An appointment, which is the default calendar item, involves only your schedule and time and does not require other attendees and resources
2. When an appointment lasts longer than 24 hours, it becomes an event.
3. An appointment becomes a meeting when you invite other people or resources.


or

i think that "ZCS Import wizard for Outlook" application can easily solve this issue. You can try it.

even you can refer to this link, as it gives you the complete details about the Calendar features of Outlook 2007

https://wiki.brown.edu/confluence/display/CISDOC/Outlook+2007+-+Calendaring+Tutorial
Shahvikas - thanks for the helpful comments, but I don't think that's quite got it.

What condition in an appointment has to be true so that when another user changes something in the notes via OWA it changes the appointment into a meeing?

Because whatever that condition is, it is being applied to appointments imported from Excel, but not being applied to appointment created from within outlook.

I need to find a way to:
a) change that condition in exisitng appointments to they don't keep changing to meetings.
b) ensure that future appointments imported from excel don't have the condition set.

I know this is the problem because it's easily repeated:
1) create an appointment in outlook, open the appointment in OWA and change something in the notes field and all is good.
2) import an appointment from excel into outlook, open the appointment in OWA and change something in the notes and the appointment changes into a meeting preventing further changes.

Any help gratefully appreciated!
Thanks guys
Charlie

Charlie,

Can you post a spreadsheet with a sample appointment?  I'd like to import it here and compare the results.
Did your issue got resolved.?
Hi Guy's
Sorry for the silence on my part, I've been kind of busy and just reinstalled my machine with a new (and legal) copy of office 2007 to see if the updates solve the issue.
I've just received the next set of appointments on excel (july to december) and will need to import them in to outlook soon, so it would be great to get this solved by then.
I'll try some experiments this evening and post the results here tomorrow.
Cheers,
Charlie
Evening experts,
OK I managed to find some time this week to take a look at this issue.
I imported the attached excel file into Outlook 2007, which worked fine, all the information imported and I now have appointments for each line in the excel file.
Next I copied the newly imported appointment to a shared folder so all the team can access them.
However, if anyone changes one of these appointments via OWA (as they are going to need to do from time to time) the appointment changes into a meeting! - Its driving me mad!
I can make changes in Outlook and it remains an appointment, but if I or another user makes a change via OWA it changes from an appointment to a meeting.
Please someone help!
Thanks people,
Charlie
2009-Faithworks-Import.xls
Are you saying that this only happens with imported appointments?  In other words, an appointment you created manually on your calendar and then copied to the shared calendar does not change to a meeting when edited via OWA?
Yes that is exactly right.
And to prove it I did the following.
(for info I have two personal diaries, 1. home, 2. work and one public diary, if you remember you (bluedevilfan) wrote a macro to sync my personal (work) dairy and the public work diary - which it working great - thank you!)
I created 4 appointments.
No1. was an imported appointment from the above excel file (imported into a temp calendar, copied to personal (work), then synced to public using your macro)
No2. I created in personal (home), copied to personal (work) then synced to public.
No3. Created in personal (work) then synced to public
No4. created in public via outlook 2007
I ran your sync macro and endied up with all 4 appointments synced in personal (work) and public.
Next I edited them in my personal (work) calendar using outlook - all remained appointments.
Next I edited them in the public shared calendar using outlook - all remained appointments
Finally I edited them in the public calendar using OWA, *and the imported appointment became a meeting*, but the other three remained appointments.
This is only happening to imported appointments!
I can run the macro at the top and convert them all back to appointments, but it would be great to understand why and prevent it happening in the first place.
What is it about an imported appointment (as opposed to a manually created appointment) that means it changes into a meeting when edited in OWA?
It seems mad to me - is it a bug, or intentional.
Thanks once again for yor help.
Charlie
Charlie,

Sorry to be so slow getting back to you on this.  Can you post one of the imported appointments?  Save it in .msg format, then change the extension to .txt and upload here.
Hi David,
Sorry for the delay, I've been on holiday!
Here's two files, the first "appointment 1" is an imported appointment un-touched. "Appointment 2" is an imported appointment that has been edited in OWA and therefore has changed into a meeting. I have six months on appointments to import from an excel spreadsheet but I'm holding off because of this problem. The alternative is entering them all by hand, but that would take days!
Thanks for your willingness to help.
Charlie
Appointment-1.txt
Appointment-2.txt
Charlie,

I hope you had a good holiday.

I can see where the item's are different.  The first difference is the MeetingStatus property.  Appointment1's MeetingStatus property is correctly set to 0, non-meeting (i.e. an appointment).  Appointment2's MeetingStatus is set to 3, meeting received.  The other difference is the ResponseStatus property.  I think this may be the cause.  Appointment2's property is set to 3, meeting accepted.  Given the MeetingStatus setting that's okay.  It's Appointment1's setting I'm concerned about.  It's set to 1, response organized, when it should be set to 0, simple appointment.  Unfortunately ResponseStatus is a read-only property so we can't change it.  The solution might be to script the import instead of using Outlook's native import.  Do you want to give that a try?
Hi David,
That seems to make sense - would you describe it as a bug? If so is there a way to report it to Microsoft for a fix?
Anyway - if a script is the solution lets go for it!
Or we could try using an intermediary format or program inbetween excel and outlook to solve the problem? I'm wondering if the issue is with excel or with outlook?
I'd be really grateful if you can think of a way to solve it.
Thanks for your help,
Charlie

P.S. Have you tried recreating the problem yourself with excel?
I'm not sure it's a bug.  My guess is that the developers at Microsoft figured that imported appointments were meetings that came from another source.  A person wouldn't typically enter their own appointments in a spreadsheet and then import them.  In other words, appointments in a spreadsheet almost certainly came from a someone or something (i.e. a foreign process) other than yourself.  I did try importing your spreadsheet and got the same results.  Scripting the import will not only fix this, but it will be simpler too (i.e. fewer choices to make and buttons to click).  I'll owrk up some code and get it posted as quickly as I can.
Charlie,

Here's the code for importing these appointments.  Follow these instructions to use it.

1.  Start Outlook
2.  Click Tools > Macro > Visual Basic Editor
3.  If not already expanded, expand Microsoft Office Outlook Objects
4.  If not already expanded, expand Modules
5.  Select an existing module (e.g. Module1) by double-clicking on it or create a new module by right-clicking Modules and selecting Insert > Module.
6.  Copy the code from the Code Snippet box and paste it into the right-hand pane of Outlook's VB Editor window
7.  Edit the code as needed.  I included comments wherever something needs to or can change
8.  Click the diskette icon on the toolbar to save the changes
9.  Close the VB Editor

Sub ImportAppointments()
    Dim excApp As Object, _
        excBook As Object, _
        excSheet As EObject, _
        olkFolder As Outlook.Folder, _
        olkAppointment As Outlook.AppointmentItem, _
        intRow As Integer, _
        datTemp As Date
    Set excApp = CreateObject("Excel.Application")
    'Change the path and file name on the next line'
    Set excBook = excApp.Workbooks.Open("C:\eeTesting\2009-Faithworks-Import.xls")
    Set excSheet = excBook.Worksheets("Sheet1")
    excApp.Visible = True
    intRow = 2
    Do While excSheet.Cells(intRow, 1) <> ""
        Set olkAppointment = Application.CreateItem(olAppointmentItem)
        With olkAppointment
            .Subject = excSheet.Cells(intRow, "A")
            .Start = CDate(excSheet.Cells(intRow, "B") & " " & CDate(excSheet.Cells(intRow, "C")))
            .End = excSheet.Cells(intRow, "D") & " " & CDate(excSheet.Cells(intRow, "E"))
            .AllDayEvent = excSheet.Cells(intRow, "F")
            .ReminderSet = excSheet.Cells(intRow, "G")
            datTemp = CDate(excSheet.Cells(intRow, "H") & " " & CDate(excSheet.Cells(intRow, "I")))
            .ReminderMinutesBeforeStart = DateDiff("n", datTemp, .Start)
            .Body = excSheet.Cells(intRow, "J")
            .Location = excSheet.Cells(intRow, "K")
            .Importance = IIf(excSheet.Cells(intRow, "L") = "High", olImportanceHigh, olImportanceNormal)
            .Sensitivity = IIf(LCase(excSheet.Cells(intRow, "M")) = "true", olPrivate, olNormal)
            .Categories = excSheet.Cells(intRow, "O")
            .Display
        End With
        intRow = intRow + 1
    Loop
    Set olkAppointment = Nothing
    Set excSheet = Nothing
    excBook.Close False
    Set excBook = Nothing
    excApp.Quit
    Set excApp = Nothing
    MsgBox "Finished"
End Sub

Open in new window

Hi David,
you are a star - that did the trick - problem solved.
Please could I ask you to just modify one thing?
At the moment the macro imports the appointments into the main outlook calendar, is it possible to add a line of code so that I can specify the calendar it imports into? i.e. calendar - temp? Then I can eyeball the import before I copy the appointments into the my main work diary and mixing them up with all my existing data.
Thanks again, your help has been fantstic.
Charlie
ASKER CERTIFIED SOLUTION
Avatar of David Lee
David Lee
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Thank you David!
Charlie
You're welcome.  Always happy to be of service.