开发者

Unable to correctly retrieve Date value from Word Template VB6 Macro

开发者 https://www.devze.com 2022-12-21 19:58 出处:网络
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-pa

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号