Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-20-2021, 10:16 AM
Cendrinne's Avatar
Cendrinne Cendrinne is offline Help with select all Shapes in headers Windows 10 Help with select all Shapes in headers Office 2019
Competent Performer
Help with select all Shapes in headers
 
Join Date: Aug 2019
Location: Montreal Quebec Canada
Posts: 190
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
  #2  
Old 04-20-2021, 02:41 PM
macropod's Avatar
macropod macropod is offline Help with select all Shapes in headers Windows 10 Help with select all Shapes in headers Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

There is no method to convert all shapes to inlineshapes in a single action. That said, try:
Code:
Sub Test()
Application.ScreenUpdating = False
Dim oSec As Section, oHftr As HeaderFooter, s As Long
For Each oSec In ActiveDocument.Sections
  For Each oHftr In oSec.Headers
    With oHftr
      If .Exists Then
        On Error Resume Next
        For s = .Shapes.Count To 1 Step -1
          .Shapes(s).ConvertToInlineShape
        Next
        On Error GoTo 0
      End If
    End With
  Next
Next
Application.ScreenUpdating = True
End Sub
Do note that, when you convert shapes to inlineshapes, there is no guarantee they will end up in their original positions. Rectifying that would require a considerable coding effort.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 04-20-2021, 04:10 PM
Cendrinne's Avatar
Cendrinne Cendrinne is offline Help with select all Shapes in headers Windows 10 Help with select all Shapes in headers Office 2019
Competent Performer
Help with select all Shapes in headers
 
Join Date: Aug 2019
Location: Montreal Quebec Canada
Posts: 190
Cendrinne is on a distinguished road
Default Thank you, I got an error message...

Quote:
Originally Posted by macropod View Post
There is no method to convert all shapes to inlineshapes in a single action.
Hello, thanks and good to know that there's no way, so I won't waste time trying.

The code provided, thank you !!! However, it does gives me an error message.

I'll try to translate, since my system is in French.
Compilation Error.
Method Member or data unfound.
And it selected the word: ShapeRange

Does that makes sense to you?

Cendrinne
Reply With Quote
  #4  
Old 04-20-2021, 04:39 PM
Cendrinne's Avatar
Cendrinne Cendrinne is offline Help with select all Shapes in headers Windows 10 Help with select all Shapes in headers Office 2019
Competent Performer
Help with select all Shapes in headers
 
Join Date: Aug 2019
Location: Montreal Quebec Canada
Posts: 190
Cendrinne is on a distinguished road
Default

Ohhhh hooo, I've tried to fix it, by Trial and error and now my Word documents are frozen or continuing thinking.

I've changed:
Do While oHftr.Shapes.Count > 0
oHftr.Shapes.range(1).ConvrtToInlineShape

is that bad? Plus I don't have a Pause Break button. I found online how to activate On-Screen Keyboard by doing this:

Hold Windows logo and press R. Type osk and press Enter to open On-Screen Keyboard.
osk, Works I mean, but the Pause in it, didn't stop my running macro.

I think I have to do Ctrl+Alt+Del then kill word, right?

Cendrinne


Update:
Under this site What is the alternative to Pause and Break keys? - Appuals.com
I've tried method 2, tried many things, but I'm not certain, I think Ctrl+Scroll Lock did the trick, or coincidence it worked right after.

I have a modern keyboard, Logitech MK850, where Pause or Break, is not indicated on the keyboard.
Reply With Quote
  #5  
Old 04-20-2021, 04:52 PM
macropod's Avatar
macropod macropod is offline Help with select all Shapes in headers Windows 10 Help with select all Shapes in headers Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

My bad. That should have been a reference to Shapes. That said, the ConvertToInlineShape method doesn't work for all Shapes (i.e. some cannot be converted). Trying to do so results in a 4120 'Bad Parameter' error. See revised code.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #6  
Old 04-20-2021, 04:53 PM
macropod's Avatar
macropod macropod is offline Help with select all Shapes in headers Windows 10 Help with select all Shapes in headers Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by Cendrinne View Post
Ohhhh hooo, I've tried to fix it, by Trial and error and now my Word documents are frozen or continuing thinking.
When it gets to that point, start the Task Manager, select the Word application and choose 'End Task'.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #7  
Old 04-20-2021, 05:06 PM
Cendrinne's Avatar
Cendrinne Cendrinne is offline Help with select all Shapes in headers Windows 10 Help with select all Shapes in headers Office 2019
Competent Performer
Help with select all Shapes in headers
 
Join Date: Aug 2019
Location: Montreal Quebec Canada
Posts: 190
Cendrinne is on a distinguished road
Default Task Manager advice on running macro, never thought of that...

Quote:
Originally Posted by macropod View Post
When it gets to that point, start the Task Manager, select the Word application and choose 'End Task'.
So it is ok to do that while macro is running? I always thought it would reset my Normal.dotm, which I was trying to avoid.

OK wow, so cool, I'm learning so much from you

Cendrinne
Reply With Quote
  #8  
Old 04-20-2021, 05:08 PM
macropod's Avatar
macropod macropod is offline Help with select all Shapes in headers Windows 10 Help with select all Shapes in headers Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by Cendrinne View Post
So it is ok to do that while macro is running? I always thought it would reset my Normal.dotm, which I was trying to avoid.
It is quite safe to do and won't reset Normal.dotm
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #9  
Old 04-20-2021, 05:11 PM
Cendrinne's Avatar
Cendrinne Cendrinne is offline Help with select all Shapes in headers Windows 10 Help with select all Shapes in headers Office 2019
Competent Performer
Help with select all Shapes in headers
 
Join Date: Aug 2019
Location: Montreal Quebec Canada
Posts: 190
Cendrinne is on a distinguished road
Thumbs up OH WOW, that works!!!!!!

Quote:
Originally Posted by macropod View Post
See revised code.

OMG, you've done it. Genious!!!!!!!
On my test document, where I've put different type of Wrap in the header, 6 out 7 is PERFECT!

The only one it didnd't, but I rarely saw it modified from PDF to Word, and put header Textboxes with wrap Thight.

I feel I owe you so much. So many of you on the forum, I owe so much.
I do want one day, if possible to write a Technical book, but I need much much more skills and experience, and wanted to thank you and share the proceeds with the people who's helped me so much in my scripts.

I won't forget about you

Thank you from the bottom of my heart

Cendrinne
Reply With Quote
  #10  
Old 04-20-2021, 06:01 PM
Cendrinne's Avatar
Cendrinne Cendrinne is offline Help with select all Shapes in headers Windows 10 Help with select all Shapes in headers Office 2019
Competent Performer
Help with select all Shapes in headers
 
Join Date: Aug 2019
Location: Montreal Quebec Canada
Posts: 190
Cendrinne is on a distinguished road
Default

Paul, since I've done Break or Pause, now my work keeps giving me that my Word is giving me a pop up message:

Interrupted Execution.
What do I do to fix that? Any idea?

Cendrinne
Reply With Quote
  #11  
Old 04-20-2021, 06:07 PM
Cendrinne's Avatar
Cendrinne Cendrinne is offline Help with select all Shapes in headers Windows 10 Help with select all Shapes in headers Office 2019
Competent Performer
Help with select all Shapes in headers
 
Join Date: Aug 2019
Location: Montreal Quebec Canada
Posts: 190
Cendrinne is on a distinguished road
Default Oh hhooo can I fix that problem?

Quote:
Originally Posted by macropod View Post
It is quite safe to do and won't reset Normal.dotm
Paul, since I've done Break or Pause, now my work keeps giving me that my Word is giving me a pop up message:

Interrupted Execution.
What do I do to fix that? Any idea?

Cendrinne

Update, I've tried everything I could think of.
I've Rebooted, and so far so good


So I'm ok so far

Night
Reply With Quote
  #12  
Old 04-20-2021, 07:39 PM
macropod's Avatar
macropod macropod is offline Help with select all Shapes in headers Windows 10 Help with select all Shapes in headers Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

If you interrupt the execution of a macro (e.g. via Ctrl-Break), there's usually a message box allowing you to resume execution; otherwise you could switch to the VBE and press F5 - or choose Run>Reset to clear the existing macro.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #13  
Old 05-31-2021, 03:34 PM
Cendrinne's Avatar
Cendrinne Cendrinne is offline Help with select all Shapes in headers Windows 10 Help with select all Shapes in headers Office 2019
Competent Performer
Help with select all Shapes in headers
 
Join Date: Aug 2019
Location: Montreal Quebec Canada
Posts: 190
Cendrinne is on a distinguished road
Default What?????? Not certain I understand

How do I switch to the VBE?
Cause since my Word is thinking, I can't do anything that has to do with Word.

I might need extra explanation here.

Cendrinne
Reply With Quote
  #14  
Old 05-31-2021, 04:14 PM
macropod's Avatar
macropod macropod is offline Help with select all Shapes in headers Windows 10 Help with select all Shapes in headers Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

You can access the VBE via Alt-F11. If Word has frozen, though, that might not be possible and might not help anyway. You may need to kill & restart Word via the Task Manager.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #15  
Old 05-31-2021, 10:44 PM
Cendrinne's Avatar
Cendrinne Cendrinne is offline Help with select all Shapes in headers Windows 10 Help with select all Shapes in headers Office 2019
Competent Performer
Help with select all Shapes in headers
 
Join Date: Aug 2019
Location: Montreal Quebec Canada
Posts: 190
Cendrinne is on a distinguished road
Default I don't know if it's frozen, but I know it's thinking

I can see the wheel turning, and all Word documents are busy, so I can't do anything. I did the last time to stop Word with task manager. Thanks that was a great suggestions.

The only thing that bothers me doing that, is I have to Re open all my word documents. Normally I have a few open already. At least 3.

But I guess if that is the easiest to do since my Word is thinking so much, it could take 30 min thinking. I think that is way too long. Right?

Cendrinne
Reply With Quote
Reply

Tags
headers; help, textboxes

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with select all Shapes in headers Control A does not select some footers and some headers Photon Word 5 04-20-2019 04:22 AM
Help with select all Shapes in headers How to see what shapes have been used ascheler Visio 1 07-08-2016 03:54 PM
Help with select all Shapes in headers Headers - Find text, Select, Pass value to Varable BrotherDude Word VBA 4 07-15-2015 05:42 PM
Help with select all Shapes in headers Can't select shapes via macro TishyMouse Word VBA 3 04-13-2012 03:26 AM
My Shapes some appear some don't Jean-Paul Visio 0 03-01-2006 01:38 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:52 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft