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.Application
Dim intRecordNo As Integer
Set dbs = CurrentDb()
Set rstCases = Forms!Cases.RecordsetClone
intRecordNo = Forms!Cases!RecordNo
rstCases.Close
'OPEN MS WORD
On Error Resume Next
AppActivate "Microsoft Word"
If Err Then
shell "C:\MSOffice\Office\WINWORD.EXE /Automation",
vbMaximizedFocus
AppActivate "Microsoft Word"
End If
On Error GoTo 0
Set appWord = GetObject(, "Word.Application")
'OPEN THE MASTER TEMPLATE
With appWord
..Documents.Add "C:\MyLibrary\Template.dot"
..ActiveDocument.ShowSpellingErrors = False
'INSERT DATA FROM ACCESS TABLE "CASES"
On Error Resume Next
' NAME
..Selection.Goto wdGoToBookmark, :="Name"
..Selection.TypeText 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.Goto wdGoToBookmark, :="Name"
..Selection.TypeText rstCases!Name & ", " Cases!Name
but it does not work. Obviously I need to declare something. Any idea
and help with code?
Thanks. 4 21420
the Three Amigos do this in the Developer Handbook... you can pass the
child recordset to the Word doc and then turn that into a table or
write it to a table... In ADH2000 it's in Chapter 12. See the
CreateTableFromRecordset function they wrote. (I'd be nice and post
it, but I didn't write it...)
Thanks friend, but could you provide me with a link where I can find the code? pi********@hotmail.com (Pieter Linden) wrote in message news:<bf**************************@posting.google. com>... the Three Amigos do this in the Developer Handbook... you can pass the child recordset to the Word doc and then turn that into a table or write it to a table... In ADH2000 it's in Chapter 12. See the CreateTableFromRecordset function they wrote. (I'd be nice and post it, but I didn't write it...)
"Paolo" <jp***@tin.it> skrev i melding
news:9f**************************@posting.google.c om... 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.Application Dim intRecordNo As Integer Set dbs = CurrentDb()
Set rstCases = Forms!Cases.RecordsetClone intRecordNo = Forms!Cases!RecordNo rstCases.Close
'OPEN MS WORD On Error Resume Next AppActivate "Microsoft Word" If Err Then shell "C:\MSOffice\Office\WINWORD.EXE /Automation", vbMaximizedFocus AppActivate "Microsoft Word" End If On Error GoTo 0
Set appWord = GetObject(, "Word.Application")
'OPEN THE MASTER TEMPLATE With appWord .Documents.Add "C:\MyLibrary\Template.dot" .ActiveDocument.ShowSpellingErrors = False 'INSERT DATA FROM ACCESS TABLE "CASES" On Error Resume Next ' NAME .Selection.Goto wdGoToBookmark, :="Name" .Selection.TypeText 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.Goto wdGoToBookmark, :="Name" .Selection.TypeText rstCases!Name & ", " Cases!Name
but it does not work. Obviously I need to declare something. Any idea and help with code?
Thanks.
Helen Feddema's website has many codesamples on how to exhange data between
office application. http://www.helenfeddema.com
Sigurd
It's here. I just found it. Search the NG for "CreateTableFromRecordset". This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Bennett Haselton |
last post by:
I'm working on an ASP.Net project where I want to test code on a local
machine using a local database as a back-end, and then export it to
the production machine where it uses the hosting...
|
by: PerryC |
last post by:
Is there a way to export an MS Access Report to Word/Excel that looks
EXACTLY like it appears in Access? When I export to Excel, only
certain data appears, titles, headings... all missing. The...
|
by: Arvind P Rangan |
last post by:
Hi all,
Have you worked on any project or example where in we can export data to
Word Format with Page Brakes and Header & Footer Template.
This is very important for my assignment.
Thanks...
|
by: jpr |
last post by:
Hello friends, I have a good question for you.
I have a form in Access with a check box named chk1.
On the same form I have a code that export my data to a template in MS
Word. I use bookmark to...
|
by: jpr |
last post by:
Friend, I am using a code to export data from a table to a word
document using bookmarks and have a problem with a date format.
When I export a field that is a mm/dd, in my word doc it shows up...
|
by: d_mike_2004 |
last post by:
Hi,
I have a web form, which display data from a Database. I'd like to
find out how to export data from webform (eg. DataSet) to an RTF file.
Would it possible to create tables in RTF as in...
|
by: Vanessa |
last post by:
hi Everyone,
I have two questions on exporting data to Excel using ASP (w/o converting
formatted excel file into web page and then plug in the dynamic data):
1. Can we export data into...
|
by: Joe Schmo |
last post by:
Is there any way to export an Access Report, including the format, into a
Word document - other than printing to a PDF.
|
by: coolminded |
last post by:
hi there,
i have a little problem with export to word. i just export the data from the grid to the word in the tabular form, but now i want to show it in the lines. i.e. all the data one by one in...
|
by: MeoLessi9 |
last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
|
by: Aftab Ahmad |
last post by:
Hello Experts!
I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
|
by: Aftab Ahmad |
last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below.
Dim IE As Object
Set IE =...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
| |