By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,360 Members | 3,011 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,360 IT Pros & Developers. It's quick & easy.

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

P: n/a


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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.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

P: n/a
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

P: n/a
I meant that to say running data accross using a mail merge (doh!).
Dave

Nov 13 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.