Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-18-2018, 03:31 PM
thecastlingking thecastlingking is offline Word Macros Issues with printing Windows 10 Word Macros Issues with printing Office 2010 64bit
Novice
Word Macros Issues with printing
 
Join Date: Jan 2018
Posts: 3
thecastlingking is on a distinguished road
Question Word Macros Issues with printing

Code:
Sub MySerial()
    Dim rngSerialLocation As Range
    Dim intSerialNum As Integer
    Dim strSerialNum As String
    Dim docCurrent As Document
    Dim intNumCopies As Integer
    Dim intCount As Integer

    ' set ref to current active doc
    Set docCurrent = Application.ActiveDocument
    ' set ref to the bookmarked serial number
    Set rngSerialLocation = docCurrent.Bookmarks("Serial").Range

    ' get the starting number
    intSerialNum = Val(rngSerialLocation.Text)
    ' get the number of copies required
    intNumCopies = Val(InputBox$("How many Copies?", _
      "Print Serialized", "1"))

    For intCount = 1 To intNumCopies
        ' print the document
        docCurrent.PrintOut Range:=wdPrintAllDocument
        ' increment the serial number
        intSerialNum = intSerialNum + 1
        ' put into formatted version
        strSerialNum = Format(intSerialNum, "00000")
        ' stuff into proper place
        rngSerialLocation.Text = strSerialNum
    Next intCount

    ' reset the bookmark, since the updating procedure
    ' wipes out the old one
    docCurrent.Bookmarks.Add Name:="Serial", _
      Range:=rngSerialLocation
End Sub
Above is the code I'm using. For whatever reason it prints out of order (like the last ten first, then the others) and the first page printed is black and white, even when colour print is selected. Can anyone help me out?

Last edited by macropod; 01-18-2018 at 11:39 PM. Reason: Added code tags & deteled unnecessary text bolding.
Reply With Quote
  #2  
Old 01-18-2018, 11:41 PM
macropod's Avatar
macropod macropod is offline Word Macros Issues with printing Windows 7 64bit Word Macros Issues with printing Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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 changing:
docCurrent.PrintOut
to:
docCurrent.PrintOut Background:=True
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 01-21-2018, 01:20 PM
thecastlingking thecastlingking is offline Word Macros Issues with printing Windows 10 Word Macros Issues with printing Office 2010 64bit
Novice
Word Macros Issues with printing
 
Join Date: Jan 2018
Posts: 3
thecastlingking is on a distinguished road
Question

Quote:
Originally Posted by macropod View Post
Try changing:
docCurrent.PrintOut
to:
docCurrent.PrintOut Background:=True
Hey there, I tried this, unfortunately it hasn't made a difference. Any other ideas?

Cheers
Reply With Quote
  #4  
Old 01-21-2018, 02:21 PM
macropod's Avatar
macropod macropod is offline Word Macros Issues with printing Windows 7 64bit Word Macros Issues with printing Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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 changing:
Background:=True
to:
Background:=False
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 01-21-2018, 02:44 PM
thecastlingking thecastlingking is offline Word Macros Issues with printing Windows 10 Word Macros Issues with printing Office 2010 64bit
Novice
Word Macros Issues with printing
 
Join Date: Jan 2018
Posts: 3
thecastlingking is on a distinguished road
Smile Solution

I figured out why it prints like this. Firstly, in the for loop, intCount was = 1 instead of 0, that's why it was B&W for the first print. For the out of order, it's due to microsofts' background printing which backlogs the first batch. All I needed to do was disable that and now it works fine.

Here's the code now:

Sub MySerial()
Dim rngSerialLocation As Range
Dim intSerialNum As Integer
Dim strSerialNum As String
Dim docCurrent As Document
Dim intNumCopies As Integer
Dim intCount As Integer

' turn off microsoft's print-out organising tool
Options.PrintBackground = False
' set ref to current active doc
Set docCurrent = Application.ActiveDocument
' set ref to the bookmarked serial number
Set rngSerialLocation = docCurrent.Bookmarks("Serial").Range

' get the starting number
intSerialNum = Val(rngSerialLocation.Text)
' get the number of copies required
intNumCopies = Val(InputBox$("How many Copies?", _
"Print Serialized", "1"))

For intCount = 0 To intNumCopies
' print the document
docCurrent.PrintOut
' increment the serial number
intSerialNum = intSerialNum + 1
' put into formatted version
strSerialNum = Format(intSerialNum, "00000")
' stuff into proper place
rngSerialLocation.Text = strSerialNum
Next intCount

' reset the bookmark, since the updating procedure
' wipes out the old one
docCurrent.Bookmarks.Add Name:="Serial", _
Range:=rngSerialLocation
' turn on microsoft's print-out organising tool
Options.PrintBackground = True
End Sub
Reply With Quote
Reply

Tags
macros in word, print

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Word Macros Issues with printing Strange missing text when printing issues laneige1990 Word 3 11-17-2015 03:59 AM
Word Macros Issues with printing Printing Issues whalescreams Word 1 12-17-2011 01:14 AM
Powerpoint printing issues DWeuve PowerPoint 0 10-04-2011 08:14 AM
Word Macros Issues with printing Excel 2010 Printing Issues - Random Quality Changes EW-ARRI Excel 2 08-18-2011 05:38 AM
Word Macros Issues with printing Excel printing issues kns Excel 2 05-01-2010 02:04 PM

Other Forums: Access Forums

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