copy between documents

  • Thread starter Michael Singmin
  • Start date
M

Michael Singmin

Hello Group,

I have a document of 1000 single entries.
Some of them are bold.
I wish to copy the non bold entries to a seperate document (VBA)

Thanks,

Michael Singmin
 
G

Graham Mayor

The following will copy the document to a new blank document, thus
preserving the original, then delete all the bold entries.

Selection.WholeStory
Selection.Copy
Documents.Add
Selection.Paste
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ""
.Font.Bold = True
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute replace:=wdReplaceAll


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
W

Word Heretic

G'day Michael Singmin <[email protected]>,

Something like this then

Publuc Sub CopyUnBoldedParagraphs()

Dim para as Paragraph
Dim source as Document
Dim target as document
Dim inserter as Range

'Define the two documents

Set Source = Activedocument
Set target = documents.add


'A means for inserting at the end of the document

Set Inserter = target.content
Inserter.collapse wdcollapseend


'Main

For each Para SourceActivedocument.paragraphs
if not para.range.font.bold then
para.range.copy
inserter.paste
inserter.collapse wdcollapseend
end if
next

'Destroy all objects

Set Inserter = Nothing
Set Target = Nothing
Set Source = nothing
end sub


Steve Hudson - Word Heretic

steve from wordheretic.com (Email replies require payment)
Without prejudice


Michael Singmin reckoned:
 

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