Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #7   Report Post  
Posted to microsoft.public.word.docmanagement
Alex St-Pierre
 
Posts: n/a
Default Best way to use a flexible word table with printmerge

Yesterday, I realized that the bookmarks are removed with the mail merge.
What I can do is to program all the modifications of tables before the mail
merge execution. This will work because only one line is merged. So, there
are two alternatives.
Thanks!
--
Alex St-Pierre


"Alex St-Pierre" wrote:

Hi Cindy,
I found the solution! I will make a Macro which execute the merge (only one
line is merge for my report). After that, I will use excel as object and
program in VBA to say to word what I need in the table (as data, line size,
format, etc.) I will use bookmark to be able to find my table easily. I think
it will be very stable.

I have already program with application events in Excel but since the
program will be used by a lot of people (which don't necessary use Office
2003), I'm not sure I really need to use it.

I will post next problems on Macro room.

Thanks!
--
Alex St-Pierre


"Cindy M -WordMVP-" wrote:

Hi ?B?QWxleCBTdC1QaWVycmU=?=,

It seems to be complex.

Indeed it does :-)

I'm good to program Macro in Excel but in Word, it is more difficult because
of the reference.. Is it possible to program a Macro that will be executing
during the merge ? Also, how can I refer table(1) as the first table,
table(2) as the second table, etc. ? (to be able to say table.delete,
table.size = (5X3), table.element(1,1) = ...
I should open the excel file, find the data table, delete the table(i) and
replacing it by the new table.

Since you are using and targeting Word 2003 you can make use of the Mail Merge
Events. Have you ever worked with application events when programming excel?
There is the MailMergeBeforeRecordMerge event that triggers before each record
is merged. This will allow you to make changes to the main merge document on a
per record basis. In the Mail Merge FAQ on my website, under "Special Merges"
there's a short discussion on creating CHARTS for mail merge. In the ZIP file
you'll find an example for using the mail merge events. I believe you'll find
another example at Graham Mayor's site (www.gmayor.com).

One thing missing in my sample code is that you need to use the Pause argument
of the .Execute method and explicitly set it to False.

You can identify the tables by the order in which they occur:
Dim doc as Word.Document
Dim tbl as Word.Table

Set doc = ActiveDocument
Set tbl = doc.Tables(1) 'first table

Or, you can mark location (in this case, an entire table) using bookmarks
(Insert/Bookmark) and address the bookmark's range.
Dim doc as Word.Document
dim rng as Word.Range
Dim tbl as Word.Table

Set doc = ActiveDocument
Set rng = doc.Bookmarks("MyFirstTable").Range
Set tbl = rng.Tables(1)

On the subject of creating tables in Word, go to the msdn site at microsoft.com
and search on my name. you should find an article on how to efficiently create
tables in Word documents.

To follow up on this, after you've done some experimenting, you should post in
one of the word.vba newsgroups. This group is targeted at end-users, so you're
less likely to find people who can help you with the ins-and-outs of writing a
complex macro. Be sure to append (copy) the code and provide all the background
information. (I'll be gone for the next ten days, or so, so won't be around to
help you here.)

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :-)


 
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Word 97 in Windows XP to maintain formatting Charlie''s Word VBA questions Microsoft Word Help 22 May 20th 23 08:51 PM
Does Word have a QuickCorrect/Quick Word option like WordPerfect? CW New Users 2 December 20th 05 05:54 PM
In Word, how do I surpress headers and footers on page 2 Bill Microsoft Word Help 1 December 15th 05 06:13 PM
is word perfect compatible with office word? Noreen Microsoft Word Help 1 May 11th 05 11:17 PM
Envelope Address GR New Users 5 April 24th 05 09:48 PM


All times are GMT +1. The time now is 12:04 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"