Macro: search text strings transfer to Excel

  • Thread starter mindful_learner
  • Start date
M

mindful_learner

Hi everyone,


Apologies in advance if this is the wrong forum for this question.


I need a simple macro to search for certain text strings in a document
and then copy these instances into an Excel document. I'm presuming
this is a rather simple task to do. I don't have time to learn VBA to
do this one-off task and I wondered if anyone had some code I could
steal/modify. Grateful thanks in advance if anyone can be so kind to
help.


Here's what I need in more detail:


I have a word document which contains text organised around headings.
For example:


Page 1
Text: a text string
Graphic: a graphic name.


I want a macro that will search for all instances of the word 'Graphic'

and then copy the text string that comes after this, which then needs
to be put in an Excel sheet. The word 'Graphic' and the following text

string is always in a table row. The text string after the word
'Graphic' always ends in a full stop. The word Graphic is always
followed by a colon.


Added complication! Sometimes the word graphic is 'Graphic_1:' or
'Graphic_2:' etc, so the initial search would have to be something like

SEARCH FOR 'Graphic*:' (i.e. use * as a wildcard character).


It would be nice if the final excel sheet could group found entries by
the page they were found on Word. E.g. if the Word document had this:


Page 1
Graphic_1: cat
Graphic_2: dog


Page 2
Graphic_1: apple
Graphic_2: pear


The final Excel sheet would have a Graphic column with


cat
dog
---- space----
apple
pear


I know this is a lot to ask, but you'd really be saving me a ton of
time. I just don't have time to start learning macro programming for
this single-task. If anyone can give me anything to get me started it
would be much appreciated. I have programmed in C and C++ before, so I

can understand any general programming instructions you need to give
me.


Kind regards
 

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