Need to extract a Date value (text) from a Word doc

P

Phil

Hello,

We have about 950 word docs that have a date value in them, to which we need
to know so we can bill them for a specific period.

Each doc has the specific date contained in this phrase: "REPORT DATE:
August 25, 2004". If it's relevant, the actual date (August 25, 2004) begins
on line 10, col 15.

All of the 950 docs have a file name in this format, eg: 1-1-111-111 and
then the DOC extension, eg: 7-5-047-053.doc

So, I need a routine that I can run WITHOUT having to open each and every
one of the word docs. If the routine needs to run inside an empty (IOW:
where no file is actually loaded or created) Word session, that's OK. The
routine needs to extract the date (AND the filename) and put them into a text
file (which I will import into Excel later) with two columns like below:

FILE NAME REPORT DATE
7-5-047-053.doc August 25, 2004*

* Note: if it is easier to change the date into another format such as
8/25/04 or whatever, that's OK with me.

Looking forward to seeing your responses!
 
H

Helmut Weber

Hi Phil,

just to get you started,
that's a lot you are asking for,
and, certainly, this is doable.

Are you able to get a list of all the files in question?

If not, see:
http://word.mvps.org/faqs/macrosvba/BatchFR.htm
http://word.mvps.org/faqs/macrosvba/ReadFoldersIntoArray.htm

The method I'm using to get a list of all files
starting from a specified folder,
from the cmd or command shell,
here the root directory, is this:

cd\
dir ?-?-???-???.doc /s /b > c:\files.txt

I'd rather not ask for a solution "at once",
but ask for help on details.

HTH

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
P

Phil

Helmut,

Yes. I can get a list. I have it in Excel format as well as a text file.
So now that I have a list, what step is next?
 
H

Helmut Weber

Hi Phil,

you have to open each file!

If speed is a matter, which seems to be the case,
with a running instance of Word,
you can open each file "invisible"
and then search the invisible doc's range.

I would not rely on column,
as you get exact results only when using non-proportional fonts.

If you got opening all docs working,
what remains is the search pattern.

Start a new thread with that,
as there are people around who no better than me.

IMHO, there is no bullet proof method.

You may search for a month's name,
followed by a space, followed by one or two digits,
followed by a comma and a space,
followed by a 4 characters long string,
which evaluates to a number between e.g 2003 and 2006.

But that's a hell of a job.


--
Gruß

Helmut Weber, MVP WordVBA

"red.sys" & chr$(64) & "t-online.de"
Win XP, Office 2003 (US-Versions)
 
D

Doug Robbins - Word MVP

You can do this with a modification of the code in the article "Find &
ReplaceAll on a batch of documents in the same folder" at:

http://www.word.mvps.org/FAQs/MacrosVBA/BatchFR.htm


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

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