View Single Post
 
Old 04-20-2021, 10:16 AM
Cendrinne's Avatar
Cendrinne Cendrinne is offline Windows 10 Office 2019
Competent Performer
 
Join Date: Aug 2019
Location: Montreal Quebec Canada
Posts: 200
Cendrinne is on a distinguished road
Default Help with select all Shapes in headers

Hello pros,
I need your insights

This is following a former thread of mine, regarding Shapes in headers.

What I'm trying to do now is to select them all and convert them to inline shape.
Cause at times, when I've converted a PDF to Word, it gives me a bunch of different types of Textboxes in headers and at times footers.

I have a wonderful Script to extract the content of the Headers, however, if in other than Inline or if they are different, it or they get's deleted. So I loose my texts.

My Test, in a Header, I've put a 7 Text box (1 under each other), for every Wrape Type there is. In this test, it's the only Header, so Primary. It might be different in live documents though.

I found a script but modified it, cause I got an error message on the line of Convert to InlineShape. Maybe because a Shape was already Inline Shape, so the reason i've added, if wrapType is not inline, then convert to inline. Now I'm getting NO errors but it doesn't do anything

Code:
     Dim oSec As Section
     Dim oHftr As HeaderFooter
     Dim i As Integer
     Dim oShp As Shapes

     For Each oSec In ActiveDocument.Sections
         For Each oHftr In oSec.Headers
           If oHftr.Exists Then
             For i = oHftr.range.ShapeRange.Count To 1 Step -1
             
               If oShpWrapType <> wdWrapMergeInline Then
               oHftr.range.ShapeRange.ConvertToInlineShape
               End If
         
             Next i
           End If
         Next oHftr
     Next oSec

    On Error GoTo 0
So either this can be fixed or have a way to Select all Shapes/textboxes in all Headers, so I can modify it manually in one shot, instead of manually changing them one at the time.

Am I asking the impossible you think?

Any advice, or insights would be sooooo greatly be appreciated

Cendrinne
Reply With Quote