Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / February 2005

Tip: Looking for answers? Try searching our database.

Word Automation Speed Slow

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DDJ - 26 Jan 2005 00:31 GMT
I took a look at this ng's FAQs and could only locate one article (by Daryl
Lucas) with some pointers regarding speeding up Word Automation from VB6.
These were fairly limited in scope...can anyone point me to some more
detailed discussions on how to speed up Word Automation?  Seems like it's
really slow from the testing I've done so far (creating tables in code seems
to be the worst).

Dan
Jezebel - 26 Jan 2005 01:49 GMT
Perhaps you could explain a little more of the issues you're dealing with?
Word automation isn't normally very slow unless you're doing silly things
like working intensively with the Selection object, using the Windows and
Panes objects, and forcing Word to repaginate continually. Some basic
tips --

- Work exclusively with Range objects. Use the Selection only for direct
interaction with the user.

- Work with screen updating switched off or, better still, with the document
or Word itself hidden.

Apart from that, VBA coding, as far as performance goes, is subject to the
same general principles as VB coding: check the VB forums and discussion
sites.

> I took a look at this ng's FAQs and could only locate one article (by Daryl
> Lucas) with some pointers regarding speeding up Word Automation from VB6.
[quoted text clipped - 4 lines]
>
> Dan
DDJ - 26 Jan 2005 03:44 GMT
Thanks for your response.

We are primarily taking data from a table used by our program and writing
the data to a report created using Word.

To give an example...one report requires the building of approx. 10, five
colum tables to output a two page report.  Without having actually measured
the time it takes, I can say that it seems to take quite a long time, in the
range of 30 seconds or more.  This, for a report that I wouldn't consider
terribly long.

I have been sticking with using Range objects; screen updating is switched
off; and Word is hidden (at least until the document has finished processing
and is opened in Preview mode).

One area in which I was hoping there would be a more efficient way to
proceed...the examples I'm using (from various help files, etc.), show each
Word table being populated cell by cell, from row to row (the "Z" pattern)
using "For Each" iterations.  Is this really the fastest way to go?  The
same goes for formatting these cells.  I think I can probably learn ways to
format the larger pieces (say at the table level) that are faster than doing
so at a lower level (the cell level).

Any input appreciated.

Dan

> Perhaps you could explain a little more of the issues you're dealing with?
> Word automation isn't normally very slow unless you're doing silly things
[quoted text clipped - 22 lines]
> >
> > Dan
Jezebel - 26 Jan 2005 04:19 GMT
I'd forgotten about that type of automation. Yes, using Word to format
output from another application can be very slow. I've given up trying to do
it at all, for exactly that reason. Word will take a couple of minutes over
a report that Access will do in half a second.

That said, in addition to Jay's suggestions: use 'With .. End With'
structures as much as possible when referring to Word objects (minimize the
dots, as they say). This improves the efficiency of the data marshalling
between the apps.

Use a template at the Word end, with named styles, rather than applying
formatting to the data you insert, and to avoid having to call Word's Page
Setup function.

Consider using Excel instead: you can paste an entire worksheet of data in a
single instruction using variant arrays. For tabular data, Excel's
formatting is pretty well as sophisticated as Word's anyway. And if you need
to top-and-tail the table, you can have a static Word document with the
spreadsheet section embedded as a linked object.

> Thanks for your response.
>
[quoted text clipped - 52 lines]
> > >
> > > Dan
Jay Freedman - 26 Jan 2005 03:56 GMT
A couple more tips:

- In general, build as much of the automation as possible in macros
within VBA, and call them from VB. The OLE interface between VB and
VBA is often the slowest part of the operation, so minimize the
message-passing between them.

- For tables specifically, the fastest method is usually to build up
the text of the table as ordinary text, with tabs between columns and
a paragraph mark at the end of each row. When it's all ready, use
ConvertTextToTable. Also see
http://www.word.mvps.org/FAQs/TblsFldsFms/FastTables.htm.

--
Regards,
Jay Freedman
Microsoft Word MVP         FAQ: http://word.mvps.org

>Perhaps you could explain a little more of the issues you're dealing with?
>Word automation isn't normally very slow unless you're doing silly things
[quoted text clipped - 22 lines]
>>
>> Dan
DDJ - 26 Jan 2005 22:46 GMT
Thanks all for the comments/suggestions.

I played with this today using some of the suggestions on the MVP site and
was able to reduce the time it takes to process tables significantly (very
significantly!).

Now I'm working trying to figure out how to reduce the resource consumption.
The CPU goes to 100% while the document is being written in code, then
(oddly) stays at 100% for a long time (60 to 120) seconds after that (I'm
using a table with five columns and 1000 rows for testing purposes).  Any
thoughts here would be appreciated.

Dan

> I took a look at this ng's FAQs and could only locate one article (by Daryl
> Lucas) with some pointers regarding speeding up Word Automation from VB6.
[quoted text clipped - 4 lines]
>
> Dan
Alex_P - 14 Feb 2005 16:47 GMT
We have applications written in VB6 which are producing large 200 - 500 pages
word documents with a lot of content, such as : pictures, tables, styles,
etc. After installation of MS Word 2003 the performance decreased
tremendously, from 40 min to 4 hours per 200 pages. We also noticed that as
document gets bigger, then we begin to notice slowing down. We contacted
Microsoft, but haven't heard the from them

> I took a look at this ng's FAQs and could only locate one article (by Daryl
> Lucas) with some pointers regarding speeding up Word Automation from VB6.
[quoted text clipped - 4 lines]
>
> Dan
AlexP - 14 Feb 2005 18:55 GMT
We have application written in VB 6.0 which costructs large Word documents
200 -500 pages with a lot of content, such as: pictures, tables, styles, etc.
It was taking about 40 min to build 200 pages document. We had used this
application from Word 97 to Word 2002. Recently we had our stations upgraded
with Office 2003 and we have experienced tremendous performance degrade. It
took about 4 hours to do the same document. Is anybody aware what happens? We
have contacted Microsoft, but so far we have not received an answer.

> I took a look at this ng's FAQs and could only locate one article (by Daryl
> Lucas) with some pointers regarding speeding up Word Automation from VB6.
[quoted text clipped - 4 lines]
>
> Dan

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.