Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Word
application.errors
conversions
docmanagement
drawing.graphics
formatting.longdocs
international
internet.assistant
mail
mailmerge.fields
menustoolbars
newusers
numbering
oleinterop
pagelayout
printingfonts
setup.networking
spelling.grammar
tables
vba.addins
vba.beginners
vba.customization
vba.general
vba.userforms
web.authoring
word6-7macros
word97vba
  
 
date: Tue, 19 Apr 2005 12:33:41 +0200,    group: microsoft.public.word.word97vba        back       


Extract formatted text to a new document   
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 12:33:41 +0200   author:   Hans List hanslist@speedpostnet

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

Re: Extract formatted text to a new document   
"Jay Freedman"
> 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

Thanks Jay!

I definitely must be having an off-day today. I'm familiar with shapes but I
didn't come up with your aproach ;-)

As a work around (and maybe this pleads for me) I converted the document to
Word 2 and re-opened it in Word 2003.

Thanks again, for your help.

Hans List
date: Tue, 19 Apr 2005 15:42:42 +0200   author:   Hans List hanslist@speedpostnet

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us