tags:

views:

10

answers:

2

I've modified a Word Template's VB6 Macros to retrieve a Date of Birth Field. Unfortunately, when the value is retrieved it has a string value prefixed by a little square block and a lot of right-padded spaces which I can't seem to trim (eg. "1/3/57 ").

Can anyone here see what the problem is? Here's the code -

If ActiveDocument.Bookmarks.Exists("dob1") = True Then
    personDOB = Mid(ActiveDocument.Bookmarks("dob1").Range.Text, 10, Len(ActiveDocument.Bookmarks("dob1").Range.Text))
    personDOB = Trim$(offenderDOB)
End If

If Not IsDate(personDOB) Then    
    Msg = "Error: Please enter an Person Date of Birth with the format dd/mm/yyyy or leave blank"
    Response = MsgBox(Msg, vbOKOnly, BadgeTitle)
End If
A: 

Not from your code, but I suspect ActiveDocument.Bookmarks("dob1").Range.Text contains Unicode characters. Can you re-enter the DOB? Does that resolve the problem?

AMissico
A: 

The old Template was written entirely in WordBasic - which doesn't seem to function anymore on client's computers. I rewrote the entire Word Template in Visual Basic, which seems to have resolved all the issues I had with it

Spacehamster