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
4 2173
The following Code Template, using only a single Command Button, will: - Open a File Dialog Box which will only allow you to select either a single, or multiple, Word Documents.
- Process each File(s) selected, and then cross reference it/them against hard coded File Names.
- Take appropriate action (Append to proper Table) depending on the File(s) selected.
- If a File(s) is/are not on the List, display an Error Message to the User that it/they cannot be Imported.
- I intentionally omitted Comments in order to reduce the length of the code, but should you have any questions, please feel free to ask
- 'Must set a Reference to the Microsoft Office XX.X Object Library
-
Dim fdg As FileDialog
-
Dim vrtSelectedItem As Variant
-
Dim strSelectedFile As String
-
-
Set fdg = Application.FileDialog(msoFileDialogFilePicker)
-
-
With fdg
-
.AllowMultiSelect = True 'allow multiple Files to be selected
-
.Filters.Clear
-
.Filters.Add "Word Documents", "*.doc"
-
.FilterIndex = 1
-
.InitialView = msoFileDialogViewDetails
-
If .Show = -1 Then
-
For Each vrtSelectedItem In .SelectedItems
-
'Retrieve 'FileName only'
-
strSelectedFile = Right$(vrtSelectedItem, Len(vrtSelectedItem) - InStrRev(vrtSelectedItem, "\"))
-
Select Case strSelectedFile
-
Case "Some File 1.doc"
-
'code specific to Some File 1.doc
-
Case "Some File 2.doc"
-
'code specific to Some File 2.doc
-
Case "Some File 3.doc"
-
'code specific to Some File 3.doc
-
Case "Some File 4.doc"
-
'code specific to Some File 4.doc
-
Case "Some File 5.doc"
-
'code specific to Some File 5.doc
-
Case "Some File 6.doc"
-
'code specific to Some File 6.doc
-
Case "Some File 7.doc"
-
'code specific to Some File 7.doc
-
Case "Some File 8.doc"
-
'code specific to Some File 8.doc
-
Case "Some File 9.doc"
-
'code specific to Some File 9.doc
-
Case "Some File 10.doc"
-
'code specific to Some File 10.doc
-
Case Else
-
MsgBox "[" & strSelectedFile & "] cannot be Imported!", vbExclamation, "Import Failed"
-
End Select
-
Next vrtSelectedItem
-
Else 'The user pressed Cancel.
-
End If
-
End With
P.S. - Be sure to set a Reference to the Microsoft Office XX.X Object Library
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
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.
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.
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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....
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
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....
|
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
|
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...
|
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...
| |