Results 1 to 6 of 6
  1. #1
    New Lounger
    Join Date
    Oct 2004
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Macro IF Page > 1 (2003 SP1)

    Hi

    We have a simple macro recorded that creates a Label based on text highlighted in, e.g., a letter.

    I would like for the Macro to check to see if the Page Count is greater than 1, and if it is, to run 'Shrink to Fit'.

    I'm sure this is possible, but I don't know where to start in structuring the code.

    Would someone be able to point me in the right direction?

    Thanks in advance.

  2. #2
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro IF Page > 1 (2003 SP1)

    See the list of Word VBA books at http://www.standards.com.
    Place to start is Steve Roman's Writing Word Macros.

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Macro IF Page > 1 (2003 SP1)

    To be a tad more specific than Howard, the number of pages in the document is <code>Selection.Information(wdNumberOfPagesInDocum ent)</code>. So perhaps something like this:

    If Selection.Information(wdNumberOfPagesInDocument) > 1 Then
    ActiveDocument.FitToPages
    End If

  4. #4
    New Lounger
    Join Date
    Oct 2004
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro IF Page > 1 (2003 SP1)

    Thank you Hans. That was, obviously, very helpful and exactly what we needed (but you knew that).

    Thanks again. [img]/forums/images/smilies/smile.gif[/img]

  5. #5
    3 Star Lounger
    Join Date
    Jun 2004
    Location
    Oxford, Oxfordshire, United Kingdom
    Posts
    203
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro IF Page > 1 (2003 SP1)

    I'm interested in the book recommended here for Word macros--but I'm concerned by how old it is. Do I need to worry?

  6. #6
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro IF Page > 1 (2003 SP1)

    I'm not aware of anything more recent.

    The basics of Word VBA have not changed.
    The details of the object model get changed with every version of Word, but no book is ever totally up to date with such detailed changes.
    For a start, the book is fine.
    Once you learn the basics, you'll get the rest from the online Help, object browser and more specialized VB/VBA books.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •