Hello,
I am trying to create a procedure to export my Access data to a word
template.
I would like to export data from two tables to a word file at the same
time. My two tables are named CASES AND CLIENTS. The word (it is a
template) is named MASTER
To store data, I have created two forms named CASES and MASTER. Since
both forms have a lot of fields, I have added the form CLIENTS as a
SubForm on the form CASES.
I have then created bookmarks on my word template and use this code to
export the data from my table CASES to the template:
Public Function MASTER()
Dim dbs As Database, rstCases As Recordset
Dim appWord As Word.Applicatio n
Dim intRecordNo As Integer
Set dbs = CurrentDb()
Set rstCases = Forms!Cases.Rec ordsetClone
intRecordNo = Forms!Cases!Rec ordNo
rstCases.Close
'OPEN MS WORD
On Error Resume Next
AppActivate "Microsoft Word"
If Err Then
shell "C:\MSOffice\Of fice\WINWORD.EX E /Automation",
vbMaximizedFocu s
AppActivate "Microsoft Word"
End If
On Error GoTo 0
Set appWord = GetObject(, "Word.Applicati on")
'OPEN THE MASTER TEMPLATE
With appWord
..Documents.Add "C:\MyLibrary\T emplate.dot"
..ActiveDocumen t.ShowSpellingE rrors = False
'INSERT DATA FROM ACCESS TABLE "CASES"
On Error Resume Next
' NAME
..Selection.Got o wdGoToBookmark, :="Name"
..Selection.Typ eText rstCases!Name & ", " Cases!Name
My problem is that I am only able to export the data from the table
CASES to the template.
I would like to be able to also export the data that I will enter in
the subform GUESTS into the same template that in the mean time has
opened as a simple word document (and named document1):
I have tried to simply add the code:
..Selection.Got o wdGoToBookmark, :="Name"
..Selection.Typ eText rstCases!Name & ", " Cases!Name
but it does not work. Obviously I need to declare something. Any idea
and help with code?
Thanks.
I am trying to create a procedure to export my Access data to a word
template.
I would like to export data from two tables to a word file at the same
time. My two tables are named CASES AND CLIENTS. The word (it is a
template) is named MASTER
To store data, I have created two forms named CASES and MASTER. Since
both forms have a lot of fields, I have added the form CLIENTS as a
SubForm on the form CASES.
I have then created bookmarks on my word template and use this code to
export the data from my table CASES to the template:
Public Function MASTER()
Dim dbs As Database, rstCases As Recordset
Dim appWord As Word.Applicatio n
Dim intRecordNo As Integer
Set dbs = CurrentDb()
Set rstCases = Forms!Cases.Rec ordsetClone
intRecordNo = Forms!Cases!Rec ordNo
rstCases.Close
'OPEN MS WORD
On Error Resume Next
AppActivate "Microsoft Word"
If Err Then
shell "C:\MSOffice\Of fice\WINWORD.EX E /Automation",
vbMaximizedFocu s
AppActivate "Microsoft Word"
End If
On Error GoTo 0
Set appWord = GetObject(, "Word.Applicati on")
'OPEN THE MASTER TEMPLATE
With appWord
..Documents.Add "C:\MyLibrary\T emplate.dot"
..ActiveDocumen t.ShowSpellingE rrors = False
'INSERT DATA FROM ACCESS TABLE "CASES"
On Error Resume Next
' NAME
..Selection.Got o wdGoToBookmark, :="Name"
..Selection.Typ eText rstCases!Name & ", " Cases!Name
My problem is that I am only able to export the data from the table
CASES to the template.
I would like to be able to also export the data that I will enter in
the subform GUESTS into the same template that in the mean time has
opened as a simple word document (and named document1):
I have tried to simply add the code:
..Selection.Got o wdGoToBookmark, :="Name"
..Selection.Typ eText rstCases!Name & ", " Cases!Name
but it does not work. Obviously I need to declare something. Any idea
and help with code?
Thanks.
Comment