Reply
 
Thread Tools Display Modes
  #1   Report Post  
Mark
 
Posts: n/a
Default Inseting another macro variable into document

I found the macro below on a web site to print out multiple copies that are
numbered. This works great, but I need to know how to add another variable
Inputbox. I would like the user to be able to enter in a Job Number that is
placed in a specific place in the document.

Sub COPIES()
'
' COPIES Macro

'
Dim varItem As Variable
Dim bExists As Boolean
Dim lCopiesToPrint As Long
Dim lCounter As Long
Dim lCopyNumFrom As Long

' ensure our doc variable exists
bExists = False
For Each varItem In ActiveDocument.Variables
If varItem.Name = "CopyNum" Then
bExists = True
Exit For
End If
Next varItem

' initialize document variable if doesn't exist
If Not bExists Then
ActiveDocument.Variables.Add _
Name:="CopyNum", Value:=0
End If

' ask how many to print
lCopiesToPrint = InputBox( _
Prompt:="How many copies?", _
Title:="Print And Number Copies", _
Default:="1")

' ask where to start numbering
lCopyNumFrom = CLng(InputBox( _
Prompt:="Number at which to start numbering copies?", _
Title:="Print And Number Copies", _
Default:=CStr(ActiveDocument.Variables("CopyNum") + 1)))

' loop through the print-write-print cycle
For lCounter = 0 To lCopiesToPrint - 1
' update the document variable
ActiveDocument.Variables("CopyNum") = _
lCopyNumFrom + lCounter
' print this numbered copy
ActiveDocument.PrintOut COPIES:=1
Next lCounter

End Sub




Thank You,
Mark

Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Word 2003 [email protected] Microsoft Word Help 39 April 19th 06 06:35 PM
SQL Prompt When opening merged documents Jeni Q Mailmerge 14 August 11th 05 09:10 PM
create a macro to update (save) document Lae Microsoft Word Help 1 June 8th 05 12:59 AM
Can you save individual document pages as seperate word files? John Calligy Mailmerge 2 April 12th 05 09:14 AM
Turning off Line Numbering Macro unformats my document! Victoria Page Layout 1 January 21st 05 12:34 AM


All times are GMT +1. The time now is 04:14 AM.

Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"