[AccessD] Semi OT - Word automation question.

MartyConnelly martyconnelly at shaw.ca
Fri Feb 11 11:45:05 CST 2005


You might want to look into Word doing a complete redraw of the page 
after every insertion
I remember running into something like this this with large documents 
say 40 pages where there was graphical columns
It took a couple of minutes just to preview. I think there is a way to 
turn off.
Maybe look here
http://www.mvps.org/word

Bobby Heid wrote:

>Hi all,
>
>I am trying out different ways to let the users design a document and using
>bookmarks and flag fields have access add data to it.  
>
>In my particular situation, there are about 10 fields that I am using
>bookmarks for.  If this were all, then I'd just automate a mail merge and be
>done with it.  The problem is, there are two tables that I need that can
>have from zero to many items in it.  
>
>What I have done is this:
>1) Start Word (hidden, no updates)
>2) Create two blank documents, one is a temp document, the other is the
>output document.
>3) For each record in the master recordset:
>	a) Clear the temp document
>	b) Copy the master document to the temp document
>	c) Change all of the bookmarks to their correct value with code
>like:
>	   .Bookmarks("Period").Range.Text = Format$(Nz(rs![Period], ""),
>"MMM, yyyy")
>	d) Search for my first table place holder, "[[WCTable]]".  If it is
>found, I select 
>	   it and replace it with "".
>	e) Insert a table with the proper number of rows (which is 3 for
>header and total 
>	   rows plus the number of detail rows for this contract).
>	f) Merge the 1st row to one cell and insert the title.
>	g) Insert the column headers into the 2nd row.
>	h) Insert the "Total" text on the last row.
>	i) Loop through a recordset and insert text from the current record
>into the 
>         correct row in the table.
>	j) Perform steps d-i except that we will be working with the second
>table.
>	k) Copy the temp document,
>	l) Append the copied temp document to the end of the output
>document.
>4) Save the output document.
>5) Close word without saving any changes.
>
>It all works ok.  The problem is that it takes approximately 2 seconds per
>document.  Does anyone have any ideas on how to speed this up?  I have a
>feeling it is how I am processing the tables.  I have read that inserting
>all the text for the tables as text into the document then converting text
>to a table is much faster, but I'm not quite sure how to do that with what I
>have to deal with.
>
>Another method that I read about was to iterate through the cells collection
>and insert the text that way.
>
>Anyone know what the best way to do this is?
>
>Sorry about the long post.
>
>Thanks,
>Bobby
>
>
>  
>

-- 
Marty Connelly
Victoria, B.C.
Canada






More information about the AccessD mailing list