Help with a macro - again!

J

jonfromdon

Help again Graham!!

The macro as described here worked wonderfully up until last week when for
some unexplained reason it now keeps putting ALL the consequtive numbers
"Order" in the Bookmarked box instead on overwriting each selected number.

Help!!
--
john


Graham Mayor said:
You are welcome :)

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Was this post helpful to you?

Why should I rate a post?
 
G

Graham Mayor

Replace the main macro code with the following revised version, and ensure
that the bookmark CertNo is present and empty. The Reset macro is OK.

Sub AddNoFromINIFileToBookmark()
Dim SettingsFile As String
Dim Order As String
Dim rRecNo As Range
Dim iCount As Integer
Dim i As Long
iCount = InputBox("Print how many certificates?", _
"Print Certificates", 1)
SettingsFile = Options.DefaultFilePath(wdStartupPath) & _
"\Settings.ini"
Order = System.PrivateProfileString(SettingsFile, _
"CertificateNumber", "Order")
If Order = "" Then
Order = 1
End If
For i = 1 To iCount
Set rRecNo = ActiveDocument.Bookmarks("CertNo").Range
rRecNo.Text = Format(Order, "00000")
With ActiveDocument
.Bookmarks.Add "CertNo", rRecNo
.Fields.Update
.ActiveWindow.View.ShowFieldCodes = False
.PrintOut Copies:="2"
End With
Order = Order + 1
Next i
System.PrivateProfileString(SettingsFile, "CertificateNumber", _
"Order") = Order
End Sub

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
J

jonfromdon

Hi Graham

Thanks for that - works a treat.
Sorry I took a while replying but other fish to fry!
Best regards
 

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