PDA

View Full Version : Search for Words with Bold Font



taporctv
07-20-2007, 05:27 AM
I've been programming excel macros for sometime but never have programmed macros for word. I need someone to point me in the right direction. Basically I have a bunch of PDFs that contain words and their definitions. The words are in bold followed by it definition in normal text.
So basically what I want to do is:
1. Manually copy the text from the pdf into word (Don't need a macro for this)
2. Run a macro the searches for bold text and copies it into an excel spreadsheet
3. Following the bold text, Id like a macro to copy the definition (normal text) and copy it into an excel spreadsheet right next to its corresponding term (the bold text)

Is this possible?

fumei
07-20-2007, 01:15 PM
Yes. But you would be better off telling us some actual details.

Are the words, ummm "words", that is...are they more than one word? A phrase? Or just one word?

Are they in a table?

Are these words always at the start of a paragraph. i do not mean a "line", but a paragraph. Something that terminates with a paragraph mark. If you do not have Show/Hide on, turn it on. How are the words / definitions terminated?

daniel_d_n_r
07-24-2007, 03:33 AM
Selection.Find.ClearFormatting
Selection.Find.Font.Bold = True
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute

fumei
07-24-2007, 02:29 PM
Sigh....

I will repeat. It would be better if you could give details.

The code above will:

1. find the first CHUNK of bolded text. If that chunk is one word, or fifty words, the entire thing will be selected.

2. It will NOT go any farther than selecting the first chunk of bolded text. It does nothing except select the first chunk of bolded text.

Poster: please use the VBA code tags. Thanks.

I will repeat. Please give details.

To suggest something though.

1. Use a Range.
2. Use Range.Find.
3. Use a Do...While loop
4. Copy each .Execute Found
5. Paste that into Excel
6. Collapse the Range after every #5
7. Move the Range to 1 character to the right.
IF this is paragraphs, not tables....which is why I am asking questions about details.
8. Expand the Range to the end of the paragraph.
IF this is paragraphs, not tables....which is why I am asking questions about details.
9. Copy that Range, and paste to Excel

Continue the Do...While loop until the end of the document.

This is not all that difficult really.

fumei
07-24-2007, 02:32 PM
BTW: one of the most important details is:

Are you doing this from Excel.....or are you doing this from Word??????

Makes a difference.