0

In my Excel workbook, I can attach an Access database as an OLE object.

I now want to save a copy of this object (Access database) in another folder.

Here is my code:

    If nameEnd = "ccdb" Then
        'Access Type

        Dim AccessApp As Object
        Dim obja As OLEObject

        Application.ScreenUpdating = False
        Set obja = ActiveSheet.OLEObjects(i)
        obja.Activate
        obja.Visible = True
        Set AccessApp = GetObject(, "Access.Application")
        AccessApp.CurrentDatabase.SaveAs FileName:=fpath & "AttachmentAccess"
        AccessApp.CurrentDb.ExportAsFixedFormat outputfilename:=saveFile & "Attachment DB", _
        ExportFormat:=accdbExportFormatPDF
        Set AccessApp = Nothing
        Range("K2:Z300").Select
        Application.ScreenUpdating = True
     End If

I get the error "Object doesn't support this property or method" probably because "CurrentDatabase.SaveAs" does not exist as a property.

Community
  • 1
  • 1
rikky
  • 1

1 Answers1

0

I think you used wrong property names.

As you write in the next line, it's not CurrentDatabase but CurrentDb. Moreover, the function isn't called SaveAs but MakeReplica. So, try this:

AccessApp.CurrentDb.MakeReplica PathName:=fpath & "AttachmentAccess"
z32a7ul
  • 3,695
  • 3
  • 21
  • 45
  • thank you! That seemed to work for me: I didn't even realize that my property names were mismatched. – rikky Feb 25 '19 at 17:47