Can anyone help on a macro problem that I have

T

tweacle

I have the following macro that im using with a set up to automatically
increase no's by 1 everytime they print.

Sub PrintAndNumber()
Dim prty As DocumentProperty
Dim bFound As Boolean
Const strPropertyName = "Ref Number"

For Each prty In ActiveDocument.CustomDocumentProperties
If UCase$(prty.Name) = UCase$(strPropertyName) Then
bFound = True
Exit For
End If
Next prty
If Not bFound Then
Set prty =
ActiveDocument.CustomDocumentProperties.Add(strPropertyName, False,
msoPropertyTypeNumber, 1)
End If
Do
ActiveDocument.Fields.Update
ActiveDocument.PrintOut
ActiveDocument.CustomDocumentProperties(strPropertyName).Value
= ActiveDocument.CustomDocumentProperties(strPropertyName).Value + 1
Loop Until
ActiveDocument.CustomDocumentProperties(strPropertyName).Value 5
End Sub

The problem im having is when I first run it its fine. When I save and
close workbook and then run macro again after reopening it dont
completely run it just prints the next no and then stops. Can anyone
help on amending the macro above so that once its completed it saves
and closes document and then when I reopen the document at a later time
it just carries on printing all the sheets increasing the ref no's when
I run the macro. Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top