Question

VBA Access code to send data to MS Word Text Box (ActiveX control)

By Jee-ar ·
Anybody can correct my string? It cannot send data to MS Word Text Box (ActiveX). Thanks in advance.
Private Sub cmdSCIDFront_Click()
Dim appword As Word.Application
Dim doc As Word.Document
Dim Path As String

On Error Resume Next
Error.Clear
Path = "C:\Users\DSWD-pc664\Documents\MSWDO\Services\AICS\2018\AICS\SC ID\SC ID Front - Copy.docx"
Set appword = GetObject(, "word.application")
If Err.Number <> 0 Then
Set appword = New Word.Application
appword.Visible = True
End If
Set doc = appword.Documents.Open(Path, , True)
With doc
.Boxes("txtFullName").Result = Me.SCFirstName & " " & Me.SCMiddleName & " " & Me.SCLastName
.Boxes("txtBarangay").Result = Me.SCBarangay
.Boxes("txtDateOfBirth").Result = Format(Me.SCDateOfBirth, "mmm-dd-yyyy")
If Me.SCSex = "Male" Then
.Boxes("txtSex").Result = "M"
ElseIf Me.SCSex = "Female" Then
.Boxes("txtSex").Result = "F"
End If
.Boxes("txtAge").Result = Fix((DateDiff("d", Me.SCDateOfBirth, Now) / 365.25))
.Boxes("txtDateIssued").Result = Format(Me.SCDateIssued, "mmm-dd-yyyy")
End With

appword.Visible = True
appword.Activate

Set doc = Nothing
Set appword = Nothing
End Sub
0 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Share your knowledge
Back to Software Forum
0 total posts (Page 1 of 1)  

Related Discussions

Related Forums