Consulting

Results 1 to 5 of 5

Thread: Export Excel data to Access table thru TransferSpreadsheet

  1. #1

    Export Excel data to Access table thru TransferSpreadsheet

    Help guys!!!

    I want to transfer my Excel data in a spreadsheet to an Access table.. but after I run my codes, it always pops up a run time error of 438 saying that the object does notsupport this property/method. Please help me.. thanks!!!

    [VBA]Sub test()

    Application.DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "excelfilesfordata.xlsx", "F:\Database51.mdb", True, ""

    End Sub[/VBA]


    tomodachi.

  2. #2
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    If you are doing this from Excel, then Application is for Excel, not Access. You need to first reference the Access object to access the method of properties of the Access object.

    There are other ways to do that in excel. See my recent posts for an alternative.

  3. #3
    Hi Kenneth,

    Really thankful for ur reply! I have seen ur recent posts but I am still not sure how to do it.. Sorry, I am a real newbie...

    And how do you reference the Access object? And Can Application still be used in this case?

    Thank you!
    'tomodachi.

  4. #4
    Hi, this is my new code that i modified. But it produces another error.... Help!!!
    [IMG]file:///C:/Users/user/AppData/Local/Temp/moz-screenshot.png[/IMG][IMG]file:///C:/Users/user/AppData/Local/Temp/moz-screenshot-1.png[/IMG][IMG]file:///C:/Users/user/AppData/Local/Temp/moz-screenshot-2.png[/IMG][IMG]file:///C:/Users/user/AppData/Local/Temp/moz-screenshot-3.png[/IMG]There is a runtime error of 3170. Application defined or object defined error. I dont know how to solve it....

    [vba]Sub happy()

    'Identify MS Access as an Object
    Dim a As Object
    Set a = CreateObject("access.application")


    '
    'Opens the MS Access Database
    a.OpenCurrentDatabase ("F:\Database51.mdb")
    a.Visible = True



    'Transfer identified range from Excel worksheet to MS Access
    a.DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "Table1", "C:\Users\user\Desktop\excelfilesfordata.xlsx", True, ""
    a.Visible = True

    End Sub[/vba]


    Thank you!
    Last edited by Aussiebear; 08-07-2010 at 12:17 AM. Reason: Applied tags to code

  5. #5
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    Here is the thread that I told you about. http://www.vbaexpress.com/forum/showthread.php?t=33393

Posting Permissions

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