Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Inserting a table into a Word Document as part of a mail merge in VBA

5 views
Skip to first unread message

Tom Dauria

unread,
Nov 11, 2003, 2:34:09 PM11/11/03
to
What I am trying to do is write a resume into a word document from
information in an Access database. I have been using bookmarks and
inserting table results into the document and so far it's working but
I have run into a problem.

The final section of the resume deals with Experience which is
subgrouped by Market Segments and then experience.

What I want it to look like is

Experience (this should be 14pt font)
Biotechnology (this should be 12pt font)

now I need to insert a table with 3 columns Position, Client/Location
and Project. The table will be in 10pt font.

As I loop through the user's experience I will need to break out of
the table drop down a line so that I can start another market segement
ie Chemical Engineering etc and then build a table for each section.

Any suggestions?

Wayne Morgan

unread,
Nov 12, 2003, 1:59:33 AM11/12/03
to
This would probably be much easier to do from the Word side.

--
Wayne Morgan
Microsoft Access MVP


"Tom Dauria" <tda...@bu.edu> wrote in message
news:56ec1535.03111...@posting.google.com...

Tom Dauria

unread,
Nov 12, 2003, 6:10:52 AM11/12/03
to
If I am using automation then I am not sure why it would matter. I
still need to programatically insert text. I actually have the

EXPERIENCE
Biotechnology

Chemical Engineering

part working now I just don't see how to create and then fill a table
from code.

I was thinking of creating a section for each of the possible market
segments. Bookark each type like Biotechnology and then book mark the
table. That way if I didn't have any experience for that subsection I
could just delete it.


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Bri

unread,
Nov 12, 2003, 11:20:19 AM11/12/03
to
Tom,

If you are using automation, the Document you are working with has a Tables
collection under it. A Table Object has an Add Method for creating Tables. Under
the Table Object there are other collections including the Cell Object which you
can reference and fill with content. Here is some air code that should work or
at least point you in the right direction:

==============================
Function MakeWordTable(stDocument As String, stNewDocument As String)
Dim objWord As Word.Application
Dim objWordDoc As Word.Document
Dim objTable As Word.Table
Dim objRange As Word.Range
Dim x As Integer, y As Integer

Set objWord = CreateObject("Word.Application")
Set objWordDoc = objWord.Documents.Open(stDocument)
objRange = objWordDoc.Goto(wdGoToBookmark, , , "Bookmark1")

Set objTable = objWordDoc.Tables.Add(objRange, 3, 5)

For x = 1 To 3
For y = 1 To 5
objTable.Cell(x, y).Range.InsertAfter "Cell " & x & "," & y
Next y
Next x

objWordDoc.SaveAs stNewDocument
objWordDoc.Close
objWord.Quit

Set objTable = Nothing
Set objRange = Nothing
Set objWordDoc = Nothing
Set objWord = Nothing

End Function

==============================

Bri

Francis Dion

unread,
Nov 14, 2003, 1:38:57 AM11/14/03
to
Hi,

We've recently implemented a solution exactly like what you are
describing for a microbiology lab in New Hampshire.

This is very easily to implement using the XpertDoc technology, an
flexible and efficient alternative to both MS-Word Mail Merge and
Automation.

XpertDoc allows you to easily define repeating sections (including
tables) and custom table break functions. And this is accomplished
using maybe 1/10 of the code you will need using Automation.

If you are interested, you can check it out at www.xpertdoc.com.

Bri <n...@here.com> wrote in message news:<75tsb.375890$6C4.92292@pd7tw1no>...

0 new messages