Unable to correctly retrieve Date value from Word Template VB6 Macro
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(Act开发者_运维知识库iveDocument.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
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?
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
精彩评论