Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-19-2013, 11:54 PM
macropod's Avatar
macropod macropod is offline Numbering labels prints Windows 7 32bit Numbering labels prints Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
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

Hi Valeria,

Try this version of the code:
Code:
Sub PrintMe()
Application.ScreenUpdating = False
Dim iStart As Long, iEnd As Long, iCount As Long, StrPages As String
Dim Shp As Shape, i As Long
On Error GoTo Done
With ActiveDocument
  iStart = .Sections.First.Headers(wdHeaderFooterPrimary).PageNumbers.StartingNumber
  If iStart = 0 Then iStart = 1
  iStart = InputBox("What is the First Number?", "Numbering Start From", iStart)
  iEnd = InputBox("What is the Last Number?", "Numbering Stop At", iStart)
  If IsNumeric(iStart) = False Or IsNumeric(iEnd) = False Then GoTo Done
  If iStart > iEnd Or iEnd = 0 Then GoTo Done
  iCount = iEnd - iStart
  For i = 1 To .Paragraphs.Count
    With .Paragraphs(i).Range
      If .Frames.Count = 0 Then
        If .Information(wdWithInTable) = False Then
          .ParagraphFormat.LeftIndent = .Characters.First.Information(wdHorizontalPositionRelativeToTextBoundary) _
            + .PageSetup.LeftMargin - .PageSetup.RightMargin
          .ParagraphFormat.Alignment = wdAlignParagraphLeft
        End If
      End If
    End With
  Next
  With .PageSetup
    .HeaderDistance = 18
    .FooterDistance = 18
    .LeftMargin = .RightMargin
  End With
  For i = .InlineShapes.Count To 1 Step -1
    Set Shp = .InlineShapes(i).ConvertToShape
    With Shp
      .RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
      .RelativeVerticalPosition = wdRelativeVerticalPositionPage
      .WrapFormat.Type = wdWrapTight
    End With
  Next
  For Each Shp In .Shapes
    With Shp
      .Anchor.Move wdStory, 1
    End With
  Next
  For i = .Tables.Count To 1 Step -1
    With .Tables(i)
      If Len(Trim(Replace(.Range.Text, Chr(13) & Chr(7), ""))) = 0 Then .Delete
    End With
  Next
  For i = .Frames.Count To 1 Step -1
    With .Frames(i)
      If .Range.Tables.Count = 0 Then .Delete
    End With
  Next
  If Len(.Range.Text) > 1 Then
    .Range.Cut
    With .Sections.First.Headers(wdHeaderFooterPrimary).Range
      .Paste
      For i = 1 To .Paragraphs.Count
        With .Paragraphs(i).Range
          If .Information(wdWithInTable) = False Then
            If Len(.Text) = 1 Then
              With .Font
                .Size = 1
              End With
            Else
              Exit For
            End If
          End If
        End With
      Next
    End With
    With .Sections.First.Footers(wdHeaderFooterPrimary)
      With .PageNumbers
        .Add PageNumberAlignment:=wdAlignPageNumberLeft, FirstPage:=True
        .RestartNumberingAtSection = True
        .StartingNumber = iStart
      End With
      .Range.Fields(1).Code.InsertAfter " \# 0000"
    End With
    With .Styles("Page Number").Font
      .Size = 16
      .Name = "Arial"
      .Bold = True
    End With
  End If
  For iCount = iStart To iEnd - 1
    StrPages = StrPages & Chr(12)
  Next iCount
  .Range.InsertAfter StrPages
  With Application.Dialogs(wdDialogFilePrint)
    If .Show <> True Then iEnd = iStart - 1
  End With
  .Range.Delete
  .Sections.First.Footers(wdHeaderFooterPrimary).PageNumbers.StartingNumber = iEnd + 1
End With
Done:
Application.ScreenUpdating = True
End Sub
Some small movements of the content seem inevitable.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Numbering labels prints Prints in half page landscape lostsoul62 Excel 2 07-22-2013 01:24 PM
Numbering labels prints Printing Issue - What is see in preview is not what actually prints - PLEASE HELP!!! clariberry Word 2 05-03-2012 10:42 AM
Numbering labels prints VBA Print Command Prints Document Twice HorizonSC Word 2 11-15-2011 03:26 AM
word only prints pictures AidyTy Word 0 12-15-2009 01:50 PM
Footer so low on page only top half prints Renee Hendershott Word 1 01-22-2006 05:09 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:11 AM.


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