ZKHADI
Member
- Local time
- Today, 09:15
- Joined
- Apr 5, 2021
- Messages
- 118
hey buddies....
i had a code of Fill word from access which was a function in which this line .FormFields("StudentName").Result = me.Student_name work properly.
but i need multiple fillword files like character certificate , leaving and more.
this code if i copy multiple time in vba so it clashes together so what i did i copied this code to module and and i will little change in it.
now the word file open when i call the module but its empty because i have no idea how i will mention the target table or form. because
in this row .FormFields("StudentName").Result = me.Student_name Me. is not working because now its out side of the form vba code.
see below image and i will attach code. how i will mention the StudentDetailTable or StudentDetailForm which are same. but how ?
See in picture in green box i highlight the row but its not working.. code also attached
i had a code of Fill word from access which was a function in which this line .FormFields("StudentName").Result = me.Student_name work properly.
but i need multiple fillword files like character certificate , leaving and more.
this code if i copy multiple time in vba so it clashes together so what i did i copied this code to module and and i will little change in it.
now the word file open when i call the module but its empty because i have no idea how i will mention the target table or form. because
in this row .FormFields("StudentName").Result = me.Student_name Me. is not working because now its out side of the form vba code.
see below image and i will attach code. how i will mention the StudentDetailTable or StudentDetailForm which are same. but how ?
See in picture in green box i highlight the row but its not working.. code also attached
Code:
Option Compare Database
Function CharacterCertificateFiller()
Dim appword As Object
Dim doc As Object
Dim Path As String
On Error Resume Next
Error.Clear
Path = "D:\College Database\Documents\CharacterCertificate.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
.FormFields("StudentName").Result = StuentRecord.Forms!Student_name
.FormFields("RegistrationNo").Result = Board_University_Registration_No
.FormFields("FatherName").Result = Father_Name
.FormFields("CurrentFaculty").Result = CurrentFacultySemester
.FormFields("Status").Result = StudentStatus
.FormFields("CellNO").Result = Cell_NO
End With
appword.Visible = True
appword.Activate
Set doc = Nothing
Set appword = Nothing
End Function