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 / November 2006

Tip: Looking for answers? Try searching our database.

Activate Word object

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
mike - 15 Nov 2006 19:24 GMT
Am working with an executable that invokes Word and preprocesses a Target
Document, I have noticed that if I don't set the objWord (application
object) to...

With objWord
  .Visible = True
  .Activate
End With

until the very end, processing the document goes much faster, however it
will randomly will finish with more than one resulting documents. That is to
say occasionally there will be a resulting Document1, Document2 and
MyDocument, each will have erroneous pieces.

With performance the goal of the effort, I hate to give up the savings by
Activating early-on but the random behavior has me concerned?

Is there a best practices for performance approach?
Shauna Kelly - 18 Nov 2006 23:15 GMT
Hi Mike

You generally get a performance gain from running word with .Visible =
False.

If you want to run with .Visible = False and not .Activate-d, then the code
itself should be written so that it will do exactly the same thing whether
or not Word is .Visible or .Activate-d.

I would suspect two likely problems with the code.

First, ensure that the code is always referring to the correct Document. For
example, don't rely on references to Word's ActiveDocument. Create a
reference to the Target Document, and use that reference consistently.

Second, don't use the .Selection. Instead, set a reference to a range, and
use that.

Hope this helps.

Shauna Kelly.  Microsoft MVP.
http://www.shaunakelly.com/word

> Am working with an executable that invokes Word and preprocesses a Target
> Document, I have noticed that if I don't set the objWord (application
[quoted text clipped - 14 lines]
>
> Is there a best practices for performance approach?
mike - 27 Nov 2006 16:26 GMT
Thank you Shauna,

I researched the usage of ActiveDocument and it looks like the original
author did implement the reference like you mentioned.

I ended up with...

With objWord
 .Visible = True
 .Activate
 .Visible = False
End With

Am getting the performance and consistency.

I will look at the Range and Selection implementations as you also
mentioned.

Thanks again, sincerely, - Mike

> Hi Mike
>
[quoted text clipped - 37 lines]
>>
>> Is there a best practices for performance approach?

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.