Consulting

Results 1 to 6 of 6

Thread: Runtime Error 438 in Access

  1. #1

    Runtime Error 438 in Access

    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!!!

  2. #2
    VBAX Contributor
    Joined
    Oct 2012
    Location
    Brisbane, Queensland, Australia
    Posts
    163
    Location
    I was sure that I had responded to this yesterday, but I cannot see my response.

    Try

    [VBA]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)
    [/VBA]

  3. #3
    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")

  4. #4
    VBAX Contributor
    Joined
    Oct 2012
    Location
    Brisbane, Queensland, Australia
    Posts
    163
    Location
    Note that I was using

    [VBA]Set myfolder1 = Olns.Folders(1) [/VBA]

    While you have used

    [VBA]Set myfolder1 = OL.Folders("Public Folders")[/VBA]

  5. #5
    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.

  6. #6
    VBAX Contributor
    Joined
    Oct 2012
    Location
    Brisbane, Queensland, Australia
    Posts
    163
    Location
    Try

    [VBA]
    Set myfolder1 = Olns.Folders("Public Folders")
    [/VBA]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •