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 21439
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: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |