Code to create Calendar Appt not working after Windows 10 Upgrade

timitfc

New member
Local time
Today, 14:36
Joined
Jun 28, 2016
Messages
7
SOLVED

Hi All,

I have recently upgraded my machine to Windows 10, and now I'm having issues getting some VBA code within Access 2003 to work. It has ran fine for the last 4 years and since upgraded to Win10 it no longer works.

The code simply posts an appointment into a Public Folder Calendar - there is more to the actual function but i have narrowed it down to the actual creation of the appointment.

Please see code below:
Code:
Public Sub PostLeave()

 Dim olfolder As Outlook.MAPIFolder
   Dim olapp As Outlook.Application
   Dim olAppt as Outlook.AppointmentItem
   Set olapp = CreateObject("Outlook.Application.14")
   Set olfolder = olapp.GetNamespace("Mapi").GetFolderFromID("000000001A447390AA6611CD9BC800AA002FC45A030018E43B268190ED4FAB3F96CD9EC40DAE006E10F9C07E0000")
   [B]Set olAppt = olfolder.Items.Add(1)[/B]
   With olAppt    'olAppointmentItem
                .AllDayEvent = True
                .start = "29/06/2016 13:00:00"
                .End = "29/06/2016 14:00:00"
                .Subject = "TEST LEAVE FUNCTION"
                .Save
   End With
   Set olfolder = Nothing
   Set olapp = Nothing
   
End Sub
Please note that it brings up an error "Method 'Items' of object 'MAPIFolder' failed" on the following line:
Code:
Set olAppt = olfolder.Items.Add(1)
Please note that this code will execute fine from within Outlook itself, but while ran from Access no luck.

Thanks for any help!
 
Last edited:
Hi All,

Has anyone got any ideas with this one? I'm still struggling to find a solution.

Thanks
Tim
 
I haven't upgraded to Windows 10 yet and I'm thinking I made the right decision!

I haven't got a clue however I think I would start looking to check to see if "Mapi" has been left out of Windows 10 you might have to add it back in or create a reference to it, something like that. Like I said, I don't know but that is my suspicion.

Sent from my SM-G925F using Tapatalk
 
Strange that it works in Outlook but not Access though?

How would i go about seeing if MAPI had been left out?

Thanks
Tim
 
FYI just to let you know this has been resolved. I think Uncle Gizmo might have been along the right lines (although wasn't sure how to actually check this). I managed to get this to work by changing from

Dim lfolder As Outlook.MAPIFolder
to
Dim olfolder As Object

Very odd as I much prefer to actually give variables their correct declaration but hey.. this works!

Thanks all for your help
 

Users who are viewing this thread

Back
Top Bottom