Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-10-2023, 05:21 AM
AllekieF AllekieF is offline Modify text in inline textbox in last section footer Windows 10 Modify text in inline textbox in last section footer Office 2021
Novice
Modify text in inline textbox in last section footer
 
Join Date: Oct 2023
Location: Netherlands
Posts: 9
AllekieF is on a distinguished road
Default Modify text in inline textbox in last section footer


Currently I am working on a template for a report which has a coloured bar in the footer with differently coloured ends as a mark-up feature, with the page number in the right side part. (________________#_)
End-users often change the page layout from portrait to landscape and page sizes. For aesthetics I would like the ends to always be the same width and the bit in-between to widen/shrink as required.

If the bar were to be placed in a table, this table would always be the same with regardless of the page layout. Unlinking the footer and setting the table to "AutoFit Window" will fill the correct width, but also widens the ends. To overcome this I have set a tab-stop at the correct width, followed by a right alignment tab, applied the correct shading to both parts and placed an inline textbox of the correct width with the page number on the right. Up to here, this works perfectly.

Now for the tricky bit...
When the user wants to use appendices in the document, they press a custom button which (through VBA) adds a Table of Appendices after the ToC, adds a section at the end of the document and applies the first appendix header. As most of the appendices are PDFs which are inserted into the PDF version of the report, page numbering of the appendices is useless as they don't make any sense anymore. So when the appendices are added in Word with the custom button, I want to remove the page numbering from the footer. And this is where I am stuck.

I have given the textbox a name for reference, but when I try to select the textbox it selects the one on a previous section, even though the footer of the last section is opened. Also I cannot find how to delete the page number from the textbox.

So my questions are:
1. How do I select the textbox in the appendix?
2. How to delete the page number from the textbox.

And if anyone has a better solution than this one I'm open to all suggestions.

Code:
Sub AddApp()
Dim rng As Range: Set rng = Selection.Range 'to return user to starting position

'Insert Next Section
Selection.EndKey Unit:=wdStory
Selection.InsertBreak Type:=wdSectionBreakNextPage
ActiveDocument.Bookmarks.Add Name:="AppStart", Range:=Selection.Range 'For reference in other procedures
'Selection.Style = "Appendix 1" 'Format Appendix header

ActiveDocument.Sections(ActiveDocument.Sections.Count).Footers(wdHeaderFooterPrimary).LinkToPrevious = False  'unlink footer from previous section
'ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter 'open footer for editing

'--> This doesn't work: select textbox containing page number and delete number
ActiveDocument.Sections(ActiveDocument.Sections.Count).Footers(wdHeaderFooterPrimary).Shapes("tbxPageNum").Select

'--> This needs to be modified to remove the page number
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.EndKey Unit:=wdLine, Extend:=wdMove
Selection.MoveLeft Unit:=wdCharacter, Count:=2, Extend:=wdExtend
Selection.Delete

'Close Footer
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument

'Insert TOA (only for docs with ToC)
If ActiveDocument.CustomDocumentProperties("Type") = "RPT" Then
    Call GetTOALocation
    Call InsertTOA
End If

rng.Select 'return to original position
End Sub
Reply With Quote
  #2  
Old 10-10-2023, 04:37 PM
Guessed's Avatar
Guessed Guessed is offline Modify text in inline textbox in last section footer Windows 10 Modify text in inline textbox in last section footer Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,977
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Working with floating objects (graphics or text boxes) in headers and footers is problematic for VBA. There have been posts in the past which have discussed this that you might gain an insight from.
https://www.msofficeforums.com/word-...all-pages.html
https://www.msofficeforums.com/word-...en-though.html

Rather than trying to address that though, I would first challenge your initial design decision.
Quote:
If the bar were to be placed in a table, this table would always be the same with regardless of the page layout. Unlinking the footer and setting the table to "AutoFit Window" will fill the correct width, but also widens the ends. To overcome this I have set a tab-stop at the correct width, followed by a right alignment tab, applied the correct shading to both parts and placed an inline textbox of the correct width with the page number on the right. Up to here, this works perfectly.
You absolutely can control the table so it automatically adapts without widening ALL columns. Set up the TABLE so it has a preferred width of 100%. Then go to the columns tab and set:
Column 1 with a preferred width of x (cm or inches)
Column 2 with no preferred width
Column 3 with a preferred width of x (cm or inches)
Then you will find that you can change the page width and the table will adapt by only changing the width of the middle column.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #3  
Old 10-13-2023, 06:23 AM
AllekieF AllekieF is offline Modify text in inline textbox in last section footer Windows 10 Modify text in inline textbox in last section footer Office 2021
Novice
Modify text in inline textbox in last section footer
 
Join Date: Oct 2023
Location: Netherlands
Posts: 9
AllekieF is on a distinguished road
Default

That did the trick, thanks!
Would have liked a solution where I did not have to unlink the footer, but unfortunately apparently that is not possible with this mark-up feature.

Now to update the rest of the macro's to accommodate this change.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Help with my script, Convert 1 Group TextBox from Inline with text toWrap Square then Ungroup Cendrinne Word VBA 4 06-03-2023 01:40 AM
Modify text in inline textbox in last section footer First page footer section vs. Footer section Marcia Word 6 02-05-2022 04:46 AM
Modify text in inline textbox in last section footer How to enter 'Page 1' from the footer menu in the right hand section, and not the middle section? Jules90 Excel 2 08-11-2021 06:44 AM
Footer image slides off-screen when made inline X-Bumble Drawing and Graphics 2 08-14-2020 12:40 AM
Modify text in inline textbox in last section footer How to put a table inline with the text Subterfuge Word Tables 2 09-22-2016 08:01 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:39 AM.


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