|
|
|
date: Tue, 19 Apr 2005 12:33:41 +0200,
group: microsoft.public.word.word97vba
back
Re: Extract formatted text to a new document
Hi Hans,
Your first idea, to delete the pictures, was a good one. You're correct,
though, that the graphic code ^g finds only in-line graphics. Still, VBA
will give you the tools to remove the floating graphics (Shape objects).
Make a backup copy of the document, in case something goes wrong and you
have to start over. Then run this macro to delete all the floating pictures
from the document:
Public Sub RemoveFloatingPics()
Dim idx As Long
For idx = 1 To ActiveDocument.Shapes.Count
ActiveDocument.Shapes(1).Delete
Next idx
End Sub
--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Hans List wrote:
> Hi All,
>
> I received a document that was created using SolidPDF (PDF >
> RTF/DOC). It contains a *lot* of images (I guess AutoCad line
> drawings) that are displayed very slowly. I cannot work in this
> document because of the slow display.
>
> I tried to remove all images, but S&R for ^g doesn't get them
> (although I activated page view). Because they are floating?
>
> So I tried to write a macro that collects all paragraphs that contain
> at least one character and copy them to a new document.
>
> The macro works fine, except for the fact ... that it also copys the
> images. How can I prevent this?
>
> BTW: I'm using Word 2003
>
> Tia!
>
> Hans List
>
>
> Sub ExtractFormattedText()
> 'extract all text from a document to a new document
> 'keeping all character formatting but loosing all types of images
>
> Dim aPar As Paragraph
> Dim myRange As Range
>
> For Each aPar In ActiveDocument.Paragraphs
> t = t + 1
> 'check whether paragraph contains text or numbers
> myCheck = aPar.Range.Text Like "*[A-Za-z0-9]*"
> If myCheck = True Then
> aPar.Range.Copy
> Set myRange = Documents("new.doc").Content
> myRange.Collapse Direction:=wdCollapseEnd
> myRange.Paste 'also pastes (floating?) images!
>
> End If
>
> Next aPar
> End Sub
date: Tue, 19 Apr 2005 09:28:45 -0400
author: Jay Freedman
|
|