Home |
Search |
Today's Posts |
#7
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
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 | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Word 97 in Windows XP to maintain formatting | Microsoft Word Help | |||
Does Word have a QuickCorrect/Quick Word option like WordPerfect? | New Users | |||
In Word, how do I surpress headers and footers on page 2 | Microsoft Word Help | |||
is word perfect compatible with office word? | Microsoft Word Help | |||
Envelope Address | New Users |