Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-17-2018, 06:52 AM
catflap's Avatar
catflap catflap is offline Get page number from object Windows 7 64bit Get page number from object Office 2013
Advanced Beginner
Get page number from object
 
Join Date: Aug 2015
Location: UK
Posts: 72
catflap is on a distinguished road
Default Get page number from object

Hi



I have a macro that loops through the text boxes in a multi-page word document and shrinks the text if it's overflowing:

Code:
For Each oShp In ActiveDocument.Shapes
      If oShp.Type = msoTextBox Then
            Do While ActiveDocument.Shapes(oShp.Name).TextFrame.Overflowing  
                  ActiveDocument.Shapes(oShp.Name).TextFrame.TextRange.Font.Shrink
            Loop
      End if
Next
Is there a nice little line I can out in here which I can use to tell the page number as the loop goes through? I have it in mind to display this on the statusbar so I get some indication of progress.

Thanks!
Reply With Quote
  #2  
Old 04-17-2018, 04:20 PM
macropod's Avatar
macropod macropod is offline Get page number from object Windows 7 64bit Get page number from object Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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

Try something based on:
Code:
Sub Demo()
Dim SBar As Boolean, oShp As Shape, i As Long, j As Long
With Application
  .ScreenUpdating = False
  SBar = .DisplayStatusBar
  .DisplayStatusBar = True
End With
For Each oShp In ActiveDocument.Shapes
  With oShp
    i = .Anchor.Information(wdActiveEndPageNumber)
    If i <> j Then
      StatusBar = "Processing page: " & i
      j = i
    End If
    If .Type = msoTextBox Then
      Do While .TextFrame.Overflowing
        .TextFrame.TextRange.Font.Shrink
      Loop
    End If
  End With
Next
With Application
  .StatusBar = False
  .DisplayStatusBar = SBar
  .ScreenUpdating = True
End With
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 04-18-2018, 01:54 AM
catflap's Avatar
catflap catflap is offline Get page number from object Windows 7 64bit Get page number from object Office 2013
Advanced Beginner
Get page number from object
 
Join Date: Aug 2015
Location: UK
Posts: 72
catflap is on a distinguished road
Default

wow - comprehensive reply!

I'll give it a go - thanks.

UPDATE - Yep, works a treat! - cheers
Reply With Quote
Reply

Tags
page number



Similar Threads
Thread Thread Starter Forum Replies Last Post
Running Head AND Page Number on First Page of Document (for APA Format) with Word 2003 DBinSJ Word 3 11-23-2016 11:52 AM
Get page number from object Page number begins at 1 when I page a page landscape oliboi Word 2 02-01-2016 06:09 AM
Get page number from object Start page number on page 3, go to page not working properly MetroBOS Word 7 01-30-2016 11:31 PM
Get page number from object Object in header or cover page? bemrick Word 5 02-18-2015 02:59 PM
Page number with chapter number but not from Heading 1 alpruett Word 5 06-04-2014 02:00 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:29 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