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

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

P: n/a
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?
Nov 12 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
This would probably be much easier to do from the Word side.

--
Wayne Morgan
Microsoft Access MVP
"Tom Dauria" <td*****@bu.edu> wrote in message
news:56**************************@posting.google.c om...
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?

Nov 12 '05 #2

P: n/a
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!
Nov 12 '05 #3

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

Tom Dauria wrote:
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?

Nov 12 '05 #4

P: n/a
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 <no*@here.com> wrote in message news:<75tsb.375890$6C4.92292@pd7tw1no>...
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

Tom Dauria wrote:
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?

Nov 12 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.