Word Table to Access

F

Fletcher Arnold

Pieter Linden said:
I tweaked Fletcher's code so you can write the Word table info to your
database...
(Apologies for bollixing up your code, Fletcher)

Pieter


Hi Pieter
By all means feel free. It's an open forum and is sometimes a relief when
others answer your posts. If you are interested in what I finally did with
it have a look at my post elsewhere in this thread. This shows an html
application with VBS/ADO which was done to see if I could post a plain text
file with all the necessary code.


Fletcher
 
F

Fletcher Arnold

Norman Scheinin said:
Fletcher,

Your code to extract data from Word tables works great. Do you also
have code to extract data from a table in the Header of a Word document?

Thanks,
Norman Scheinin
(e-mail address removed)

Hi Norman
It is simply a case of navigating your way through Word's object model to
get at what you want. I am not an expert on long documents created in Word,
but I tested this little snippet to get some info out of a table in the
header of a simple Word document.
If you have more complicated documents, headers can be different for
odd/even pages, for different sections, etc but this might give you a start
so you can start to have a more thorough investigation of the Word object
model.

Set wdHdr = wdDoc.Sections(1).Headers(wdHeaderFooterPrimary)

If wdHdr.Range.Tables.Count > 0 Then
Set wdTbl = wdHdr.Range.Tables(1)
MsgBox wdTbl.Cell(2, 2).Range.Text
Set wdTbl = Nothing
End If

Set wdHdr = Nothing


Fletcher
 
R

Ruby Tuesday

Hi Fletcher, thanks for posting the code.
How do you execute Xtractor.hta file?
When use IE6, it prompt me with a form(which I filed in) but without
'submit' button to execute. Perhaps I overlook something ...

Thanks again.
 
F

Fletcher Arnold

Ruby Tuesday said:
Hi Fletcher, thanks for posting the code.
How do you execute Xtractor.hta file?
When use IE6, it prompt me with a form(which I filed in) but without
'submit' button to execute. Perhaps I overlook something ...

Thanks again.

You fill in 3 things:

1: The folder where your Word documents are stored. The program imports
all tables from all documents in that folder, so if you only want a few
documents done, you could move them to their own folder first. This will
also be the folder where the MS Access database is created. You can type
the folder path e.g C:\MyStuff or use the "change folder" button.

2: The name of the database - which might as well be left as
"WordTables.mdb"

3: The maximum number of columns which will be imported from each Word
table into the database.

**The final step is to press the "Import Tables" button which should firstly
create a new Access db for the results (or prompt you to overwrite an
existing one). It then takes each table in each Word document in the
specified folder and imports the contents into the new database. When it
has finished, it gives you the chance to open the database immediately.

That is the theory, anyway and it did work perfectly on my machine, although
it does take a while for large numbers of tables. Or did you already press
the import button and something didn't work?


Fletcher
 
R

Ruby Tuesday

Hi Fletcher,
when I ran the Xtractor.hta, it and set the correct folder path and the
access db, it keeps telling me that the folder is 'Non-Existant'.

I also try to hardcoded the path, and came back the same error. Did I
overlook something? Thanks
 
F

Fletcher Arnold

Ruby Tuesday said:
Hi Fletcher,
when I ran the Xtractor.hta, it and set the correct folder path and the
access db, it keeps telling me that the folder is 'Non-Existant'.


Are you giving the name of an existing folder where the Word documents are?
What happens if you place an example Word document in the root folder (C:\)
so you do not touch the default settings of the form?

If you want to speed up communications, let me know an e-mail address and
I'll send you mine.


Fletcher
 
P

Pieter Linden

Fletcher,
just a thought... You could use the BrowseFolder API from mvps.org
and then just let the user browse for the folder... Makes it a bit
more flexible, that's all.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top