lf
Sun Mar 18 09:38:11 CDT 2007
Thank you for the feedback. I am glad I could help you.
I wish you luck with your book.
--
Regards
Lene Fredborg
DocTools - Denmark
www.thedoctools.com
Document automation - add-ins, macros and templates for Microsoft Word
"Mickmoo" wrote:
> Thanks Lene
>
> You are a real lifesaver. You code worked like a dream.
> I converted the sub to a function and ran it from the immediate window and
> low and behold I had a new document containing all my dialogue!
> I'm cuurently in the middle of editing my book and this will allow me to
> accurately gauge the proportion of dialogue to narrative.
>
> Once again many thanks.
>
>
>
> "Lene Fredborg" wrote:
>
> > I think the macro below will do what you want. The macro creates a new
> > document and uses Find to get all dark blue text strings and inserts each
> > string into the new document. Two paragraph marks are added after each string
> > in order to make sure they are properly separated (since I donâ??t know how
> > your document is formatted).
> >
> > See this article if you need help on installing macros:
> >
http://www.gmayor.com/installing_macro.htm
> >
> > Sub ExtractBlueTextToNewDocument()
> >
> > Dim oDoc As Document
> > Dim oNewDoc As Document
> > Dim oBlueRange As Range
> > Dim n As Long
> >
> > Set oDoc = ActiveDocument
> > 'Create document to be used for extraction of blue text
> > Set oNewDoc = Documents.Add
> >
> > oDoc.Activate
> > Selection.HomeKey (wdStory)
> > With Selection.Find
> > .ClearFormatting
> > .Text = ""
> > .Font.Color = wdColorDarkBlue
> > .Forward = True
> > .Wrap = wdFindStop
> > Do While .Execute
> > Set oBlueRange = Selection.Range
> > 'Insert selected text in oNewDoc - end with 2 paragraph marks
> > oNewDoc.Content.InsertAfter oBlueRange.Text & vbCr & vbCr
> > 'Count how many text strings found
> > n = n + 1
> > Loop
> > End With
> >
> > 'Activate the new document
> > oNewDoc.Activate
> >
> > 'Clean up
> > Set oDoc = Nothing
> > Set oNewDoc = Nothing
> > Set oBlueRange = Nothing
> > Selection.Find.ClearFormatting
> >
> > 'Finished - show message
> > MsgBox "Finished extracting " & n & " blue text strings to new document."
> >
> > End Sub
> >
> > --
> > Regards
> > Lene Fredborg
> > DocTools - Denmark
> > www.thedoctools.com
> > Document automation - add-ins, macros and templates for Microsoft Word
> >
> >
> > "Mickmoo" wrote:
> >
> > > Hi,
> > >
> > > Forgive my ignorance but I am new to Word Programming.
> > >
> > > I need to be able to search a document character by character. If the
> > > Character is formatted as "Dark Blue" in colour I need to extract the
> > > character from the source document to a new document (target) and continue
> > > search and extract until the end of the source document is reached.
> > >
> > > I know this request may sound a bit odd, so here's the reason why.
> > >
> > > I've written a book (approximately 280000 words - 640 pages) and I want to
> > > be able to extract just the Dialogue (enclosed by single quotation marks and
> > > formatted in Dark blue, so that it stands out from the narrative)
> > >
> > > The entire source document is written in font : Times New Roman, regular, 12
> > > point
> > > I have only used the "normal" paragraph style.
> > >
> > > The situation is complicated by that the fact that only part of any given
> > > paragraph may be dark blue (dialogue) which the rest is Black (narrative)
> > >
> > > What I'm hoping for is a single target document that contains just the
> > > dialogue (Dark Blue text)
> > >
> > > Any thoughts on this conundrum would be much appreciated.
> > >
> > > Mnay thanks
> > >