PDA

View Full Version : Runtime Error 438 in Access



toneslinger
05-22-2013, 12:45 PM
Hello, I know enough VBA to be dangerous and that is about it. A while back I created a script in a database to recognize an open Outlook session, go to one of the public folders and to download emails into the database. This has worked just fine for years. That ended today. The company upgraded to Windows 7 with MS Office 2010. Now when I run the script I get the Run-Time Error 438 - Object doesn't support this property of method. Here is the code.

'Recognize open session of Outlook.
Set OL = GetObject("", "Outlook.Application")
Set Olns = OL.GetNamespace("MAPI")
'Assign Public Folders to variables.
Set myfolder1 = OL.folders("Public Folders") - This is the line where the error occurs.
Set myfolder2 = myfolder1.folders("All Public Folders")
Set myfolder3 = myfolder2.folders("Department/Division")
Set myfolder4 = myfolder3.folders("Web Based Quote Exceptions")
Set myfolder5 = myfolder4.folders("Deleted Items")

Any advice out there? I would greatly appreciate it!!!

Doug Robbins
05-26-2013, 08:23 PM
I was sure that I had responded to this yesterday, but I cannot see my response.

Try

Dim OL As Object
Dim Olns As Object
Dim myfolder1 As Object
Set OL = GetObject("", "Outlook.Application")
Set Olns = OL.GetNamespace("MAPI")
Set myfolder1 = Olns.Folders(1)

toneslinger
05-28-2013, 05:26 AM
Thanks for the info! However, I did not post the part of the code that preceeded where it was failing. I already had those lines in there. Here is the code with the preceeding lines as well.

DoCmd.Hourglass True
Dim OL As Object
Dim Olns As Object
Dim myfolder1, myfolder2, myfolder3, myfolder4, myfolder5 As Object
Dim numitems As Integer
Dim myitems As Object
Dim db As Database
Dim RS, RSsorted As Recordset
Dim specificitem As Object
Dim Found As Boolean
Dim Track, CurrentSTN, Created_By As String
'Recognize open session of Outlook.
Set OL = GetObject("", "Outlook.Application")
Set Olns = OL.GetNamespace("MAPI")
'Assign Public Folders to variables.
Set myfolder1 = OL.Folders("Public Folders")
Set myfolder2 = myfolder1.Folders("All Public Folders")
Set myfolder3 = myfolder2.Folders("Department/Division")
Set myfolder4 = myfolder3.Folders("Web Based Quote Exceptions")
Set myfolder5 = myfolder4.Folders("Deleted Items")

Doug Robbins
05-28-2013, 02:36 PM
Note that I was using

Set myfolder1 = Olns.Folders(1)

While you have used

Set myfolder1 = OL.Folders("Public Folders")

toneslinger
06-05-2013, 05:58 AM
Hello, I tried your code and still received the error. The reason for assigning folder 1 to Public Folders is because the folder I need to access is down the public folder tree. Public Folders, then to All Public Folders, then to Department/Division, then to Web Based Quote Exceptions, then to Deleted Items. If I just tell it to set myfolder1 to Olns.Folders(1) it doesn't know to start going down that Public Folder tree.

Doug Robbins
06-05-2013, 03:40 PM
Try



Set myfolder1 = Olns.Folders("Public Folders")