Results 1 to 8 of 8

Thread: [RESOLVED] Pulling data from Word/Excel files from MS Access

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2006
    Posts
    27

    [RESOLVED] Pulling data from Word/Excel files from MS Access

    I'm considering designing somewhat cumbersome system (there are some good reasons for this choice) for data gathering.

    The scenario:

    Word/Excel documents will be filled in with information, such as name, age etc... Is there any way Access can pull this data out of the files and insert it into the database?

    Note, I'm familiar with VB 6.0, but have not done any recent VB stuff and thus not familiar with VB .NET.
    Last edited by oioioi; Mar 15th, 2006 at 08:43 PM. Reason: Updated thread to indicate the problem/issue was 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: Pulling data from Word/Excel files from MS Access

    Welcome to the Forums.

    Yes, you would need to Add a reference to MS Word or Excel xx.0 Object Library. Then how would the file be identified? GetOpenFile dialog letting the user to choose or read a directory?
    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
    Junior Member
    Join Date
    Mar 2006
    Posts
    27

    Re: Pulling data from Word/Excel files from MS Access

    Thanks RobDog888.

    I'm thinking Access will process all the word/excel files in one directory/folder. Just process them one by one and move the completed files to a different directory/folder.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Mar 2006
    Posts
    27

    Re: Pulling data from Word/Excel files from MS Access

    I'm completely new to VBA type programming. Is there anyone who can give me a few more pointers or hints on how to get started.

    What does it mean to "add a reference" to "Excel Object Library"?

  5. #5
    Frenzied Member DKenny's Avatar
    Join Date
    Sep 2005
    Location
    on the good ship oblivion..
    Posts
    1,171

    Re: Pulling data from Word/Excel files from MS Access

    Quote Originally Posted by oioioi
    What does it mean to "add a reference" to "Excel Object Library"?

    In the VBA editor for MSAccess under the Tools Menu select "References".

    In the References dialog, check the box beside the "Microsoft Excel x.x Object Library". This will add a refeerence to that library, which in turn will allow you to create and manipulate Excel objects within your Access VBA code.
    Declan

    Don't forget to mark your Thread as resolved.
    Take a moment to rate posts that you think are helpful

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Mar 2006
    Posts
    27

    Re: Pulling data from Word/Excel files from MS Access

    DKenny,

    Thanks for the pointer. Can you show me some code? Like how to create an Excel Object Library object.

    Is there a good place to search for object methods/properties?

    I find it incredibly hard to find class information for VB programs as opposed to Java.

  7. #7
    Frenzied Member DKenny's Avatar
    Join Date
    Sep 2005
    Location
    on the good ship oblivion..
    Posts
    1,171

    Re: Pulling data from Word/Excel files from MS Access

    Quote Originally Posted by oioioi
    Can you show me some code? Like how to create an Excel Object Library object.
    Sure, here some code that instantiates Excel, a workbook and a worksheet.
    VB Code:
    1. Sub sample()
    2. Dim appExcel As Excel.Application
    3. Dim wkbSampleBook As Workbook
    4. Dim wksSampleSheet As Worksheet
    5.  
    6.     Set appExcel = New Excel.Application
    7.     Set wkbSampleBook = appExcel.Workbooks.Add
    8.     Set wksSampleSheet = wkbSampleBook.Worksheets(1)
    9.    
    10.     Debug.Print wksSampleSheet.Name
    11.    
    12.     Set wksSampleSheet = Nothing
    13.     wkbSampleBook.Close False
    14.     Set wkbSampleBook = Nothing
    15.     appExcel.Quit
    16.     Set appExcel = Nothing
    17. End Sub

    Quote Originally Posted by oioioi
    Is there a good place to search for object methods/properties?

    I find it incredibly hard to find class information for VB programs as opposed to Java.
    The object Browser (F2)
    Declan

    Don't forget to mark your Thread as resolved.
    Take a moment to rate posts that you think are helpful

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Mar 2006
    Posts
    27

    Re: Pulling data from Word/Excel files from MS Access

    Thanks DKenny,

    I modified the code and it works beatifully.

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