Consulting

Results 1 to 4 of 4

Thread: Solved: Problem with AutoNumbering system...

  1. #1
    VBAX Regular
    Joined
    May 2004
    Location
    Driffield, East Yorkshire, Egnland
    Posts
    69
    Location

    Solved: Problem with AutoNumbering system...

    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...

    [VBA]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[/VBA]
    If anyone can help I'd be very grateful!

    Ad

  2. #2
    VBAX Regular Kelly's Avatar
    Joined
    Jun 2004
    Location
    Los Angeles, California
    Posts
    84
    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:
    [vba]Word.ActiveDocument.Tables(3).Cell(2, 5).Range.Text = ""[/vba]

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

    Does that work for you?

    It seems to be working for me.

  3. #3
    VBAX Regular Kelly's Avatar
    Joined
    Jun 2004
    Location
    Los Angeles, California
    Posts
    84
    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.....

  4. #4
    VBAX Regular
    Joined
    May 2004
    Location
    Driffield, East Yorkshire, Egnland
    Posts
    69
    Location
    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 Ad

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •