PDA

View Full Version : Solved: Problem with AutoNumbering system...



Adaytay
08-17-2004, 02:59 AM
Hi folks - a relatively simple problem for you.

I had a form that was issued to our claims department which they would use to log telephone claims. The form was recently redesigned to be in 'landscape' rather than 'portrait' format.

However for some reason now the autonumbering system has stopped working - rather than being in the format CLMnnnnnn, the systems' messed up the numbering sequence.

Here's the code - I've attached the document too...

Private Sub cmdPrintForms_Click()

Dim CurrentReference As String, lngReference As Long, i As Integer

If MsgBox("This will print out 10 copies of this document - proceed?", vbYesNo + vbQuestion, "Print Blanks?") = vbNo Then Exit Sub

Application.ScreenUpdating = False

Me.cmdPrintForms.Width = 0
Me.cmdPrintForms.Height = 0
For i = 1 To 10

CurrentReference = ActiveDocument.BuiltInDocumentProperties("Keywords")
lngReference = CLng(Right(CStr(CurrentReference), 6))
lngReference = lngReference + 1
CurrentReference = "CLM" & Format(lngReference, "000000")
Word.ActiveDocument.Tables(3).Cell(2, 5).Range.Text = ""
Word.ActiveDocument.Tables(3).Cell(2, 5).Range.Text = CurrentReference
ActiveDocument.BuiltInDocumentProperties("Keywords") = CurrentReference
'ActiveDocument.PrintOut Background:=True, Copies:=1

Next i
Me.cmdPrintForms.Height = 31.5
Me.cmdPrintForms.Width = 98.25

'MsgBox Copies & " documents were printed successfully!", vbOKOnly & vbInformation, "Printing Successful!"

Application.ScreenUpdating = True

' With ActiveDocument
' .Save
' .Close
' End With
'
End Sub
If anyone can help I'd be very grateful!

Ad

Kelly
08-17-2004, 07:14 PM
This is so freaky!

I think I may have fixed it, but I'm still freaked-out because I don't know why my solution seems to be working.

Try replacing the line:
Word.ActiveDocument.Tables(3).Cell(2, 5).Range.Text = ""

With this instead:
Word.ActiveDocument.Tables(3).Cell(2, 5).Range.Delete

Does that work for you?

It seems to be working for me.

Kelly
08-17-2004, 07:17 PM
But the freaky part is what the document was doing for me BEFORE i changed anything.

The part about "lngReference = lngReference + 1" was working, and indeed the newly incremented number was getting entered into the appropriate cell each time, BUT SO WAS AN EXTRA DIGIT. That's the part that I can't figure out. Where is this phantom digit coming from? It's obviously not coming from the code. There has got to be a weird hidden field or something in the document, but I can't find it, yet.....

Adaytay
08-18-2004, 12:50 AM
Hi Kelly,

That's exactly what I was experiencing too... initially there were two digits that were being added on.

The weird thing is that the code was unchanged (apart from the reference) for the "portrait" version, which worked flawlessly!!!

Anyway, it's fixed - thanks for the input, really appreciated - the document has now been rolled out to everyone!

Have a great day :D Ad