473,326 Members | 2,805 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Need YOUR PROFESSIONAL HELP to Import Word Document in MS Access Tables

Hello,

My problem is that I receive different Word Documents as attachments

and I need to get its data into the corresponding tables in access.


I have used Text Form Fields in Word Document and could save it in text format

and imported it in ms access, but this way takes long time.

So, I need your help to have a command button that when clicked I get a

browse window that enables me to choose the Word Documents (.doc Only) I want to import.

And as I have different Word Documents, I think I will need different command

buttons for each Word Document as each would be knowing which table to

import to.

Also is there anyway to minimize the possibility of importing a Document to the wrong table?

Is it possible to make the access import all documents saved in a specific folder to a specific table? I know this is fiction

Thank YOU and I really Trust Your Abilities in Solving my problem.

And I Really Appreciate your HELP
Oct 1 '08 #1
4 2173
ADezii
8,834 Expert 8TB
The following Code Template, using only a single Command Button, will:
  1. Open a File Dialog Box which will only allow you to select either a single, or multiple, Word Documents.
  2. Process each File(s) selected, and then cross reference it/them against hard coded File Names.
  3. Take appropriate action (Append to proper Table) depending on the File(s) selected.
  4. If a File(s) is/are not on the List, display an Error Message to the User that it/they cannot be Imported.
  5. I intentionally omitted Comments in order to reduce the length of the code, but should you have any questions, please feel free to ask
Expand|Select|Wrap|Line Numbers
  1. 'Must set a Reference to the Microsoft Office XX.X Object Library
  2. Dim fdg As FileDialog
  3. Dim vrtSelectedItem As Variant
  4. Dim strSelectedFile As String
  5.  
  6. Set fdg = Application.FileDialog(msoFileDialogFilePicker)
  7.  
  8. With fdg
  9.   .AllowMultiSelect = True         'allow multiple Files to be selected
  10.   .Filters.Clear
  11.   .Filters.Add "Word Documents", "*.doc"
  12.   .FilterIndex = 1
  13.   .InitialView = msoFileDialogViewDetails
  14.     If .Show = -1 Then
  15.       For Each vrtSelectedItem In .SelectedItems
  16.         'Retrieve 'FileName only'
  17.         strSelectedFile = Right$(vrtSelectedItem, Len(vrtSelectedItem) - InStrRev(vrtSelectedItem, "\"))
  18.           Select Case strSelectedFile
  19.             Case "Some File 1.doc"
  20.               'code specific to Some File 1.doc
  21.             Case "Some File 2.doc"
  22.               'code specific to Some File 2.doc
  23.             Case "Some File 3.doc"
  24.               'code specific to Some File 3.doc
  25.             Case "Some File 4.doc"
  26.               'code specific to Some File 4.doc
  27.             Case "Some File 5.doc"
  28.               'code specific to Some File 5.doc
  29.             Case "Some File 6.doc"
  30.               'code specific to Some File 6.doc
  31.             Case "Some File 7.doc"
  32.               'code specific to Some File 7.doc
  33.             Case "Some File 8.doc"
  34.               'code specific to Some File 8.doc
  35.             Case "Some File 9.doc"
  36.               'code specific to Some File 9.doc
  37.             Case "Some File 10.doc"
  38.               'code specific to Some File 10.doc
  39.             Case Else
  40.               MsgBox "[" & strSelectedFile & "] cannot be Imported!", vbExclamation, "Import Failed"
  41.           End Select
  42.       Next vrtSelectedItem
  43.     Else 'The user pressed Cancel.
  44.     End If
  45. End With
P.S. - Be sure to set a Reference to the Microsoft Office XX.X Object Library
Oct 1 '08 #2
Thank You ADezii,

but I have only one more thing to add which is that the file names I receive are

not static as some dates and numbers would be added to the original file name.

and I think this what causes the problem with the code

Thanks ALOT
Oct 1 '08 #3
ADezii
8,834 Expert 8TB
Thank You ADezii,

but I have only one more thing to add which is that the file names I receive are

not static as some dates and numbers would be added to the original file name.

and I think this what causes the problem with the code

Thanks ALOT
The code can be modified to accommodate 'Unique', 'Original' File Names. A simple example of what I am referring to would be if a Base File Name was Financial Report. The code can be modified to accept: Third Quarter Financial Report, Financial Report for the Fiscal Year 2008, Projected Financial Report for 2010, etc. Let me know if you are interested, and if you have Unique, Base/Original File Names.
Oct 1 '08 #4
Hello ADezii,

infact the name of the document should be written exactly in the code so that I

would be able to import it and if there is any change in the name of the file the

code gives an error that it can't import it it..

anyway even I made the table name with same name of the file and the import

apparently finishes successfully,then I don't find any data entered in the table.
Oct 1 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

41
by: Ruby Tuesday | last post by:
Hi, I was wondering if expert can give me some lite to convert my word table into access database. Note: within each cell of my word table(s), some has multi-line data in it. In addition, there...
3
by: svdh2 | last post by:
I have been looking at a problem the entire week in access, I have still not been able to find a solution. Hope that you could maybe tell where to look Concerns the link between Access and Word....
1
by: Srini | last post by:
Hi, I am trying to import an xml file which has more than 255 fields. Access is unable to import the xml file into tables and gives the error message "Too many fields defined." in ImportErrors...
10
by: Neil | last post by:
An article at http://news.com.com/2100-1012-991694.html?tag=fd_top states: "XML would allow easier interchange of data generated in Office documents with back-end systems or existing Web...
2
by: Mikey | last post by:
Sample VB .NET source code to create mailing labels or customized letters using MS Word MailMerge This VB .NET source code will start MS Word and call methods and set properties in MS Word to...
2
by: a.crowley | last post by:
I have a large set of Word documents that I wish to catalogue in an Access database. Each document has a set of file properties populated (title, subject, author, keywords, comments ect), so I'd...
20
by: mike | last post by:
I help manage a large web site, one that has over 600 html pages... It's a reference site for ham radio folks and as an example, one page indexes over 1.8 gb of on-line PDF documents. The site...
1
by: =?ISO-8859-1?Q?S=F8ren?= | last post by:
Hi guys I got the following code: ------------------------------------------------------- Dim Word As New Microsoft.Office.Interop.Word.Application Dim Document As...
0
by: shivapadma | last post by:
i want to know how multiple tables are added to the MS word document using vb.net i wrote following code to insert one table in MS word document using vb.net 1.opened MS word document 2.inserted...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.