M
Mark
I am trying to print out a selected range of pages with the below code but
the print fails to complete. Please can someone assist with a solution.
Sub Print_Guidance()
Dim i As String
Dim s As String
Dim t As String
Dim u As String
Dim v As String
Dim w As String
Dim x As String
Dim PagesToPrint As String
Application.ScreenUpdating = False
ActiveDocument.Unprotect Password:=""
Selection.EndKey Unit:=wdStory
Selection.InsertBreak Type:=wdPageBreak
Application.DisplayAutoCompleteTips = True
ActiveDocument.AttachedTemplate.AutoTextEntries("Guidance"). _
Insert Where:=Selection.Range, RichText:=True
ActiveDocument.Repaginate
i = ActiveDocument.BuiltInDocumentProperties("Number of Pages")
s = CStr(i - 6)
t = CStr(i - 5)
u = CStr(i - 4)
v = CStr(i - 3)
w = CStr(i - 2)
x = CStr(i - 1)
'
i = CStr(i)
PagesToPrint = s & "," & t & "," & u & "," & v & "," & w & "," & x & ","
& i
Application.PrintOut FileName:="", Range:=wdPrintRangeOfPages, Item:= _
wdPrintDocumentContent, Copies:=1, Pages:=PagesToPrint,
PageType:=wdPrintAllPages, _
Collate:=True, Background:=True, PrintToFile:=False
Selection.MoveUp Unit:=wdLine, Count:=377, Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1
ActiveDocument.Sections(1).ProtectedForForms = True
ActiveDocument.Sections(2).ProtectedForForms = True
ActiveDocument.Sections(3).ProtectedForForms = True
ActiveDocument.Sections(4).ProtectedForForms = True
ActiveDocument.Sections(5).ProtectedForForms = True
ActiveDocument.Sections(6).ProtectedForForms = False
ActiveDocument.Protect Password:="", NoReset:=True, Type:= _
wdAllowOnlyFormFields
Application.ScreenUpdating = True
End Sub
the print fails to complete. Please can someone assist with a solution.
Sub Print_Guidance()
Dim i As String
Dim s As String
Dim t As String
Dim u As String
Dim v As String
Dim w As String
Dim x As String
Dim PagesToPrint As String
Application.ScreenUpdating = False
ActiveDocument.Unprotect Password:=""
Selection.EndKey Unit:=wdStory
Selection.InsertBreak Type:=wdPageBreak
Application.DisplayAutoCompleteTips = True
ActiveDocument.AttachedTemplate.AutoTextEntries("Guidance"). _
Insert Where:=Selection.Range, RichText:=True
ActiveDocument.Repaginate
i = ActiveDocument.BuiltInDocumentProperties("Number of Pages")
s = CStr(i - 6)
t = CStr(i - 5)
u = CStr(i - 4)
v = CStr(i - 3)
w = CStr(i - 2)
x = CStr(i - 1)
'
i = CStr(i)
PagesToPrint = s & "," & t & "," & u & "," & v & "," & w & "," & x & ","
& i
Application.PrintOut FileName:="", Range:=wdPrintRangeOfPages, Item:= _
wdPrintDocumentContent, Copies:=1, Pages:=PagesToPrint,
PageType:=wdPrintAllPages, _
Collate:=True, Background:=True, PrintToFile:=False
Selection.MoveUp Unit:=wdLine, Count:=377, Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1
ActiveDocument.Sections(1).ProtectedForForms = True
ActiveDocument.Sections(2).ProtectedForForms = True
ActiveDocument.Sections(3).ProtectedForForms = True
ActiveDocument.Sections(4).ProtectedForForms = True
ActiveDocument.Sections(5).ProtectedForForms = True
ActiveDocument.Sections(6).ProtectedForForms = False
ActiveDocument.Protect Password:="", NoReset:=True, Type:= _
wdAllowOnlyFormFields
Application.ScreenUpdating = True
End Sub