Results 1 to 3 of 3

Thread: how to open excel file in microsoft access 2003?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2004
    Location
    malaysia
    Posts
    89

    Resolved how to open excel file in microsoft access 2003?

    Hi guys, why i got probelm open an excel file in microsoft access 2003?
    please help.


    Dim xlApp As Excel.Application
    Dim xlBook As Excel.Workbook
    Dim xlWSheet As Excel.Worksheet

    Set xlApp = New Excel.Application
    xlApp.Workbooks.Open Filename:=Me.txtFilePath.Value
    Set xlBook = xlApp.Workbooks
    Set xlWSheet = xlBook.Worksheets(1)

    when my code run until the open method, it come out error, of "application deined error or object-defined error".

    i think Access 10 and Access 11 use different open method.
    can anyone help or give a code snippet?
    Last edited by kkc; Oct 11th, 2005 at 05:04 AM. Reason: resolved

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: how to open excel file in microsoft access 2003?

    I take it that your trying to pass in a Access textbox objects value and not a vb6 one.
    VB Code:
    1. xlApp.Workbooks.Open Filename:=Form1!txtFilePath.Value
    Also, if your trying to do an import you can use the .TransferSpreadsheet method to do it in one line of code.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Lively Member
    Join Date
    May 2004
    Location
    malaysia
    Posts
    89

    Re: how to open excel file in microsoft access 2003?

    actually my code is working, it is just that the file corrupted.

Posting Permissions

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



Click Here to Expand Forum to Full Width