Help with a macro - again!

  • Thread starter Thread starter jonfromdon
  • Start date Start date
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?
 
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

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
Hi Graham

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