473,654 Members | 3,098 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 12369
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.goo gle.com...
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(s tDocument As String, stNewDocument As String)
Dim objWord As Word.Applicatio n
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("W ord.Application ")
Set objWordDoc = objWord.Documen ts.Open(stDocum ent)
objRange = objWordDoc.Goto (wdGoToBookmark , , , "Bookmark1" )

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

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

objWordDoc.Save As stNewDocument
objWordDoc.Clos e
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.375 890$6C4.92292@p d7tw1no>...
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(s tDocument As String, stNewDocument As String)
Dim objWord As Word.Applicatio n
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("W ord.Application ")
Set objWordDoc = objWord.Documen ts.Open(stDocum ent)
objRange = objWordDoc.Goto (wdGoToBookmark , , , "Bookmark1" )

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

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

objWordDoc.Save As stNewDocument
objWordDoc.Clos e
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
1093
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 of launching word from my app and get ACCESS DENIED when the Word attempts to start. Once the merge is complete, the document gets saved and sent to the user to open and further edit if necessary. The initial merge part doesn't have to
2
12511
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 to output a new Word .doc file with the template filled in with the record I've generated. (To refresh your memory, in Word a mailmerge is achieved by a) under Tools -> Letters and Mailings, check off Show Mail Merge Toolbar; b) open a document...
2
3239
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 generated (or before), assign the current date to the field in the main table the query data source is based on. Is this even possible? If so, how could I do it? Here is the code that works so far:
4
6284
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 like to be able to populate the Word document with the contents of the currently selected Access record so that when I press the button in Access, Word opens with the appropriate fields populated and ready to print. It is a "one off" event which I...
7
4181
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, the program tracks when notifications are sent out and who sends them. Currently these notifications are all sent via email. Now the program users also want the ability to send these notifications via standard snail mail. (I'll make a popup...
2
3371
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 confirm that I want to run a query to select the data from the data source file, then it opens the form letter fine. I can preview the merged records and complete a merge to a new document. I have a VB 2006 project (.net framework 2.0) which opens the...
3
12015
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 until I manually press 'View Merged Data' button in Word. The data then appears as expected. If I perform the 'wrdMailMerge.Execute(ref oTrue);' call I get two documents
1
6543
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!) upgraded from Access 2000 to Access 2007. Now that component is failing. The merge is building the data source file fine (text file named merge.888). I am providing an absolute path reference to the word file being used for the mail merge. ...
1
5050
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 very little (actually probably nothing) about VBA and I'm currently learning my way around Access. Basically, I want to click a button in the form that merges the letter for me, only for the one record I'm currently viewing..not the whole...
0
8375
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8815
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8707
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8593
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7306
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5622
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4294
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2714
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
1
1916
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.