Reply
 
Thread Tools Display Modes
  #1   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

I have a standard report which is produced using Word and Excel (printmerge).
In the standard report, I have tables which can vary (lines name, number of
items, column width)
I have try different solutions (2) and all of them have signifiant problems.
Does anyone have already done something like that ?

Approach #1:
I have add all tables in Excel and link it to Word using:
Link Excel.Sheet.8 "Variable_path" "Variable_cells".
The tables are very flexible but I have the following problems:
1- Standard Excel Underline height is defined as 1/2 point in Word and I
would like to have 1/4 point in Word (Would like to find a way to adjust Word
height in excel)
2- The link is not stable, Word 2003 SP3 jam often.
3- The file path name must be inside excel as a variable; I would like to
point directly to the same excel file as printmerge.

Approach #2:
All tables are make inside Word using variables. Since I want a line between
each table line, I can't put all conditions in a box.
The problems with this Approach a
1- The table column width can't be adjusted.
2- Since I want to have border between each elements, I have to create split
the table in n box with condition on each box.
It always insert one empty line between each elements.
ex: IF( Mergefield Item9 ) "" "
Table with border
" "") (this give a line between each table line)

would like to have:
ex: IF( Mergefield Item9 ) ""
"Table with border"
"") (Impossible to add " in the same line as the table line)

Does it exist other solutions to my problem ??
Is there a table merge function in Word ??
(Only one excel data line is used for the text merge and tables could takes
source from excel)
Thanks.
--
Alex St-Pierre
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Cindy M -WordMVP-
 
Posts: n/a
Default Best way to use a flexible word table with printmerge

Hi ?B?QWxleCBTdC1QaWVycmU=?=,

Approach #1:
I have add all tables in Excel and link it to Word using:
Link Excel.Sheet.8 "Variable_path" "Variable_cells".
The tables are very flexible but I have the following problems:
1- Standard Excel Underline height is defined as 1/2 point in Word and I
would like to have 1/4 point in Word (Would like to find a way to adjust Word
height in excel)
2- The link is not stable, Word 2003 SP3 jam often.
3- The file path name must be inside excel as a variable; I would like to
point directly to the same excel file as printmerge.

I've replied to point 1 in a different posting of yours, in another group
(word.tables, probably). I don't understand what you're asking with point 3.

Approach #2 is not possible in Word (point 3). Mail merge makes no special
provision for laying out tables.

Given that the Link field gives you problems, I doubt that using a Database
field will be much better for you, but you could try it. Use the Insert Database
button on the Data toolbar.

Other than this, the only remaining recourse would be to generate the tables
using VBA (a macro).

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 :-)

  #3   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

Hi Cindy,
Concerning point 2:
In excel, I had already include the table data as database field to be
flexible.
This solution can work well but the risk of problems are very high.

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.
It seems to be complex.

--
Alex St-Pierre


"Cindy M -WordMVP-" wrote:

Hi ?B?QWxleCBTdC1QaWVycmU=?=,

Approach #1:
I have add all tables in Excel and link it to Word using:
Link Excel.Sheet.8 "Variable_path" "Variable_cells".
The tables are very flexible but I have the following problems:
1- Standard Excel Underline height is defined as 1/2 point in Word and I
would like to have 1/4 point in Word (Would like to find a way to adjust Word
height in excel)
2- The link is not stable, Word 2003 SP3 jam often.
3- The file path name must be inside excel as a variable; I would like to
point directly to the same excel file as printmerge.

I've replied to point 1 in a different posting of yours, in another group
(word.tables, probably). I don't understand what you're asking with point 3.

Approach #2 is not possible in Word (point 3). Mail merge makes no special
provision for laying out tables.

Given that the Link field gives you problems, I doubt that using a Database
field will be much better for you, but you could try it. Use the Insert Database
button on the Data toolbar.

Other than this, the only remaining recourse would be to generate the tables
using VBA (a macro).

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 :-)


  #4   Report Post  
Posted to microsoft.public.word.docmanagement
Cindy M -WordMVP-
 
Posts: n/a
Default Best way to use a flexible word table with printmerge

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 :-)

  #5   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

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 :-)




  #6   Report Post  
Posted to microsoft.public.word.docmanagement
Cindy M -WordMVP-
 
Posts: n/a
Default Best way to use a flexible word table with printmerge

Hi ?B?QWxleCBTdC1QaWVycmU=?=,

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.

Good luck with the project, then :-) A word of warning, however: The execution
of mail merge to a new document will remove the bookmark. So you may, instead,
want to insert some kind of placeholder text then use Range.Find to pick that
up, delete it, and insert the table. (When you execute Range.Find or
Selection.Find the range/selection moves to the found location.)

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 :-)

  #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 :-)


Reply
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 07:19 AM.

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"