473,383 Members | 1,922 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

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

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
4 12343
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Andy | last post by:
I am trying to do the following from an ASP.NET Web Application (C#). User fills out a form. The program takes those answers and merges them with a WORD document. I have tried the few examples...
2
by: Steve M | last post by:
I'm trying to do invoke the mail merge functionality of MS Word from a Python script. The situation is that I have a template Word document, and a record that I've generated in Python, and I want...
2
by: William Wisnieski | last post by:
Hi Everyone, Access 2000 I have some code behind a button that performs a word merge with a query data source. The merge works fine. But what I'd like to do somehow is after the merge is...
4
by: Dadio | last post by:
Hello On my Access database form I have a command button which opens a Word mail merge document in which I have created a number of fields (Title, FirstName, LastName, Address1 etc.) I would...
7
by: Ryan | last post by:
Ok.. here's my situation. I have a program that handles a database full of people. Users of the program have the ability to send out notifications to these people. Pretty standard notifications,...
2
by: Colin Halliday | last post by:
I have a Word 2003 mail merge main document (form letter) that is linked to another Word document data source for the mail merge. If I open this doc using the Word GUI, it first asks me to...
3
by: Bishman | last post by:
Hi, I have some issues with the code below. These are: ONE: In code I open an existing document and 'attach' the Mail Merge data source, but the data is not poulating the merge fields...
1
by: Esther Lane | last post by:
Hello! First off, many many thanks to Albert who wrote the Mail Merge code for MS Access I am using. It has been working beautifully for a few years. However, my client just (without notice!)...
1
by: kayberrie | last post by:
I want to write a VBA mail merge code. I want to link the code/macro/dohicky to a nifty little button so it makes life easy. I think I can handle the button part, the code part - not so much. I know...
1
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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 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.