![]() |
|
|
|
#1
|
|||
|
|||
|
Hi Everyone, So my question is can I have a word document that has a work order number in the header look for that work order number in Excel and then grab the serial number in Excel and import it to the serial number field in word? Then I would also like it to print x amount of copies and have the serial number go up by one for each paper that is printed? So for example I would print 25 sheets with work order WO-0500 in the upper right. I would like it to pull the first serial number from Excel that has the WO-0500 and print 25 copies with each copy changing the serial number up by one. |
|
#2
|
|||
|
|||
|
There are lots of examples for pulling data from Excel available from a Google search. As for printing sequentially numbered copies, you could adapt the following to use your Excel value as the starting number:
Code:
Sub PrintNumberedCopies()
Dim NumCopies As String
Dim StartNum As String
Dim Counter As Long
Dim oRng As Range
If MsgBox("The copy number will appear at the insertion point." _
& " Is the cursor at the correct position?", _
vbYesNo, "Placement") = vbNo Then End
If ActiveDocument.Saved = False Then
If MsgBox("Do you want to save any changes before" & _
" printing?", vbYesNoCancel, "Save document?") = vbYes Then
ActiveDocument.Save
End If
End If
StartNum = Val(InputBox("Enter the starting number.", "Starting Number", 1))
NumCopies = Val(InputBox("Enter the number of copies that" & _
" you want to print", "Copies", 1))
ActiveDocument.Bookmarks.Add Name:="CopyNum", Range:=Selection.Range
Set oRng = ActiveDocument.Bookmarks("CopyNum").Range
Counter = 0
If MsgBox("Are you sure that you want to print " _
& NumCopies & " numbered " & " copies of this document", _
vbYesNoCancel, "On your mark, get set ...?") = vbYes Then
While Counter < NumCopies
oRng.Delete
oRng.Text = StartNum
ActiveDocument.PrintOut
StartNum = StartNum + 1
Counter = Counter + 1
Wend
End If
lbl_Exit:
Exit Sub
End Sub
|
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Word Field Update | MANOHAR | Word VBA | 6 | 06-17-2018 07:18 PM |
| Update & Unlink Specific Merge Field in Word Doc from Mail Merge - Excel VBA | RMerckling | Mail Merge | 16 | 05-17-2018 05:19 PM |
| sequentially numbering one worksheet | kromertma | Excel Programming | 1 | 08-02-2016 12:01 AM |
Can field dynamically update?
|
namedujour | Word | 2 | 03-04-2016 10:21 PM |
Sequentially numbering a document
|
UniAdmin | Word VBA | 1 | 02-21-2013 07:25 PM |