473,569 Members | 2,765 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Making a word document with VBA in Access or Word? Examples from other users



Dear All,

I have lately strugled more and more with Access, what started as a
simple database has brought me to the fundaments of Access.

I need to transfer fields from various tables to a word-document to
make a decent report (transferring a report from access to word means a
lot of loss on lay out, which I find a clear showcase of microsoft's
socalled software quality).

I can not use queries to combine the tables and a send one to word
(with mailmerge). I have one main table (A) ...and 8 subtables (B-H).
Each record in A has a varying number of records in B-H. Sofar, I have
not been able to make one table for a record in A that combines all the
relevant records in the table B-H

Now I am trying to do it with VBA. I wonder whether it is better to
open a doc file from out of Access or whether it is better to make a
VBA module in Word itself. For both approaches I see some advantages
and disadvantages but since I am rather new to VBA I would not be
surprised to encounter major obstacles later on that I can not foresee
rightnow.
For example, i need to make tables in the word-doc. Is it better to do
this from out of Access (wirth VBA) or directly in Word (with VBA), or
maybe it does not make a difference at all?

I would be glad if people could send some of there VBA codes in which a
Word-doc is opened from out of Acces and where fields from multiple
tables are send to Word. Preferable even VBA code in which tables are
constructed in the Word-Doc

Nov 13 '05 #1
4 3361
On 23 Dec 2004 01:09:21 -0800, sv***@yahoo.com wrote:
Dear All,

I have lately strugled more and more with Access, what started as a
simple database has brought me to the fundaments of Access.
You might want to look up the word "fundament" or perhaps that is what you
meant <g>.
I need to transfer fields from various tables to a word-document to
make a decent report (transferring a report from access to word means a
lot of loss on lay out, which I find a clear showcase of microsoft's
socalled software quality).
Well, it is a limitation of Access. Eveything has its limits though.
I can not use queries to combine the tables and a send one to word
(with mailmerge). I have one main table (A) ...and 8 subtables (B-H).
Each record in A has a varying number of records in B-H. Sofar, I have
not been able to make one table for a record in A that combines all the
relevant records in the table B-H

Now I am trying to do it with VBA. I wonder whether it is better to
open a doc file from out of Access or whether it is better to make a
VBA module in Word itself. For both approaches I see some advantages
and disadvantages but since I am rather new to VBA I would not be
surprised to encounter major obstacles later on that I can not foresee
rightnow.
For example, i need to make tables in the word-doc. Is it better to do
this from out of Access (wirth VBA) or directly in Word (with VBA), or
maybe it does not make a difference at all?

I would be glad if people could send some of there VBA codes in which a
Word-doc is opened from out of Acces and where fields from multiple
tables are send to Word. Preferable even VBA code in which tables are
constructed in the Word-Doc


I don't have any code to send you at the moment, but I seem to recall that
on-line examples are plentiful, and should not be hard to find with Google.

Regarding your question of whether it would be easier to do in Word or in
Access, the hardest parts of the problem all center asound the MS Word API, so
you may want to write the code in MS Word, though once it's written, you may
find it desirable to convert that to automation code that runs form Access,
and that's not hard to do.

Another option is to save your template Word document in XML format, and use
Access and the MSXML library to transform the XML to produce your output
document. The learning curve is much steaper this way, but when you factor in
debugging time MS Word API quirks, VB reference versioning, etc., the XML way
might win by a hair. Another advantage of XML is that MS Word need not even
be installed on the machine that generates the document. You could translate
the code into a VB COM library called from an ASP application running on a
server later on, and it would still work.
Nov 13 '05 #2
Being an Access programmer rather than a Word programmer, my tendancy has
always been to do the programming from Access. To manipulate Word, I can
always record macros in Word, then transfer them to my Access code.

As for constructing tables in Word -
I imagine you could record a macro for that,
but I've found it much easier to use a Word template which was already laid
out with the elements I needed. I could then just use them as I saw fit.
<sv***@yahoo.co m> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. .


Dear All,

I have lately strugled more and more with Access, what started as a
simple database has brought me to the fundaments of Access.

I need to transfer fields from various tables to a word-document to
make a decent report (transferring a report from access to word means a
lot of loss on lay out, which I find a clear showcase of microsoft's
socalled software quality).

I can not use queries to combine the tables and a send one to word
(with mailmerge). I have one main table (A) ...and 8 subtables (B-H).
Each record in A has a varying number of records in B-H. Sofar, I have
not been able to make one table for a record in A that combines all the
relevant records in the table B-H

Now I am trying to do it with VBA. I wonder whether it is better to
open a doc file from out of Access or whether it is better to make a
VBA module in Word itself. For both approaches I see some advantages
and disadvantages but since I am rather new to VBA I would not be
surprised to encounter major obstacles later on that I can not foresee
rightnow.
For example, i need to make tables in the word-doc. Is it better to do
this from out of Access (wirth VBA) or directly in Word (with VBA), or
maybe it does not make a difference at all?

I would be glad if people could send some of there VBA codes in which a
Word-doc is opened from out of Acces and where fields from multiple
tables are send to Word. Preferable even VBA code in which tables are
constructed in the Word-Doc

Nov 13 '05 #3
Speaking from experience running data accross proved to cause too many
problems. It is much easier to use a combination of bookmarks in a word
document and automating the process from within access. (And it's
really fantastically quick if you can get it right).

Here is a weblink to look at, that might give you an idea.

http://www.helenfeddema.com/CodeSamples.htm look for Access-Word
section and there is a "Merging to word 4 ways".
Looks like you may be spoilt for choice ;-)

Dave

Nov 13 '05 #4
I meant that to say running data accross using a mail merge (doh!).
Dave

Nov 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2754
by: |-|erc | last post by:
Hi! Small challenge for you. The index.php uses this file and calls layout(). Take a look at www.chatty.net this file draws the chat login box on the right. I traced the CHAT button it submits and goes to the index file again, I can't figure out how it opens the chatroom. I want to get it to skip the login box and go straight to the...
4
7627
by: Jeff Harbin | last post by:
I've got an ACCESS 2000 application that I'm developing. One of the outputs of this app will be to generate a series of 'jobs' which corresponds to a record in the database. Each record will be printed on its own page which I've set up as a report and that's working fine. Accompanying each job is a Word (or Excel) document. Most jobs will...
3
3807
by: intl04 | last post by:
Is it possible to create a Word form as the data entry form for an Access database? I didn't see any reference to this possibility in my Access books, so I'm sorry if this is a question that is rather off-the-wall. I was asked to ask this question, to see if a Word form can be linked to an Access database and then emailed to various end-users...
4
2394
by: astro | last post by:
I've been looking at the event sinking example in Litwin et. al. "Access 97 Developer's Handbook" and I am able to event sink the 2 events listed - those being the "_quit" and "_documentchange" events described and coded for in the examples mdb file.. However - some other important events I cannot get to work - some are: ...
16
1718
by: Simon Verona | last post by:
I have a problem with automating MS Word through vb.net My code is : Dim objword As new Word.ApplicationClass Try objWord.Documents.Open(letterfile) objWord.Documents.Item(letterfile).Activate() Catch MsgBox("Error - Word Not running properly - letterfile=" & letterfile &
351
12839
by: CBFalconer | last post by:
We often find hidden, and totally unnecessary, assumptions being made in code. The following leans heavily on one particular example, which happens to be in C. However similar things can (and do) occur in any language. These assumptions are generally made because of familiarity with the language. As a non-code example, consider the idea...
5
3728
by: jmar | last post by:
I posted a week ago and received one response. I'm looking for the opinion of several experienced .NET people before I proceed so I'm posting again. Sorry for the repost... I am updating a VB4.0 quote generation program to VB.net. The old program takes user inputs, performs calculations, saves the data to Access databases and uses...
8
6692
by: babyangel43 | last post by:
Hello, I have a query set up in Access. I run it monthly, changing "date of test". I would like this query to be merged with a Word document so that the cover letter is created in Word, the fields from Access are automatically filled into the Word document. The query could be anywhere from 0-5000 names, one cover letter per name. AND to this...
0
7612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7924
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8120
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7968
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6283
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5512
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.