Performance issue

P

Peter Karlström

Hi

I have developed a fairly large COM Addin for Word/Excel which helps my
customer to design and format their documents and spreadsheets.
The installation is +200 clients and we have a handfull (about 5) of them
experiencing performance problems.
We have made som logging adjustments to the code to be able to time the
different steps and to narrow the problem.
There are two seperate occasions with similar code that takes a lot of time
on these problem clients but executes as lightning on the rest. We have
checked the PC's CPU and RAM but that isn't the issue. Some has more memory
and faster CPU's then non-problem clients. It is not a Profile issue(central
profiles), since the problem disappears if the user logs on to a different PC.
The code involves pasting of AutoTextEntries from a loaded template into a
range in the documents header.
The code below takes approximately 17 seconds to execute. How is that
possible?

Code explanations:
MallDoc = a document which is loaded from a template with AutoTextEntries.
actDoc = the document which is beeing worked with.
Standard1 = the name of the AutoTextEntry. It contains a table with
bookmarks. The table is in 6 columns and 4 rows, but some of them are merged.
Before this step in the code the header is completely emptied.

+++++ code start
Set rngHeaderFirstPage =
wrdApp.Windows(actDoc).Document.Sections(1).Headers(wdHeaderFooterFirstPage).Range

wrdApp.Windows(Malldoc).Document.AttachedTemplate.AutoTextEntries("Standard1").Insert Where:=rngHeaderFirstPage
rngHeaderFirstPage.Tables(1).PreferredWidthType = wdPreferredWidthAuto
rngHeaderFirstPage.Tables(1).PreferredWidth = 0
rngHeaderFirstPage.Tables(1).Rows.SetLeftIndent -45, wdAdjustNone
rngHeaderFirstPage.WholeStory
rngHeaderFirstPage.ParagraphFormat.SpaceAfter = 0
rngHeaderFirstPage.ParagraphFormat.SpaceAfterAuto = False
rngHeaderFirstPage.Font.Name = "Times New Roman"

+++++ code end

Any suggestion or hint to how we can solve this is much appreciated.

Thanks in advance
 
A

Andrei Smolin [Add-in Express]

Hi Peter,

Does this happen for long documents? Do you set ScreenUpdating to false
while updating the header?

Regards from Belarus (GMT+2),

Andrei Smolin
Add-in Express Team Leader
www.add-in-express.com
 
P

Peter Karlström

Hi Andrei

No, the documents are mostly empty at this stage in the process.
Screenuppdating is False. As a matter of fact, the Word application is
unvisible during this part.

Regards

--
Peter Karlström
Midrange AB
Sweden


Andrei Smolin said:
Hi Peter,

Does this happen for long documents? Do you set ScreenUpdating to false
while updating the header?

Regards from Belarus (GMT+2),

Andrei Smolin
Add-in Express Team Leader
www.add-in-express.com
 
J

Jialiang Ge [MSFT]

Hello Peter,

In my best guess, it is because Maildoc was having trouble to access its
attached template in the code:
wrdApp.Windows(Malldoc).Document.AttachedTemplate.AutoTextEntries("Standard1
").Insert Where:=rngHeaderFirstPage

Where is the template file located? Is it in a network share? Any chance
that the network connection of the five computers is causing the problem?
To verify this hypothesis, we can either use Procmon.exe to trace the
hanging period, or create a "Maildoc" from a local copy of the template and
see if the add-in can run smoothly based on this new "Maildoc".

If it does not help, would you tell me the Office & OS (64bit?) version of
the computers? It was mentioned that you used log to trace the operations.
Is it possible for you to detect the exact line of code that hangs in your
code snippet? You may consider splitting some long code lines into small
fragments, and log the operation time for each piece. For example:

Set doc = wrdApp.Windows("maildoc.doc").Document
Regards,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
P

Peter Karlström

Hi Jialiang Ge

Thanks for your reply.

The Malldoc template is located localy and is only 52kB small.
The loading of the template takes less than a second and is executed just
before in the code I supplied earlier. Up till we timed the opening I also
considered network load, but thats not the issue.

The clients are 32-bit PCs running Windows XP SP2 with Office XP (2002) SP3.

In an overall comparement some clients creates documents on 5-7 seconds,
while others use almost 2 minutes with the exact same conditions. This part I
supplied in my first post is the one with the biggest timeloss.
We have also checked other loaded COM Addins, and if we unload them we get
an increase in performance but we do not reach under 30 seconds for creation
of a document.

I guess, as you also suggest, that we have to narrow the debugging down even
more to logg every line of code in this part of the process.
I will talk to the client and discuss the logging increase. Then I will get
back to you.


Regards
--
Peter Karlström
Midrange AB
Sweden
 
P

Peter Karlström

Hi Jialiang Ge

Now we have tested with a timestamp for every row of the "problem-code".
Below is the interesting logparts. Logging is made immidiately before the
code-execution.
+++++ log excerpt start +++++
2008-05-28:14:39:36; Load document template
2008-05-28:14:39:37; Get PageSetup-margin from template and set to document
2008-05-28:14:39:37; Set rngHeaderFirstPage
2008-05-28:14:39:37; Insert AutotextEntry Standard1
2008-05-28:14:39:37; Set Tables(1).PreferredWidthType = wdPreferredWidthAuto
2008-05-28:14:39:43; Set Tables(1).PreferredWidth = 0
2008-05-28:14:39:48; Set Tables(1).Rows.SetLeftIndent -45
2008-05-28:14:39:51; Set rngHeaderFirstPage.WholeStory
2008-05-28:14:39:51; Set ParagraphFormat.SpaceAfter = 0
2008-05-28:14:39:51; Set ParagraphFormat.SpaceAfterAuto = False
2008-05-28:14:39:51; Set Font.Name = 'Times New Roman' = False
+++++ log excerpt end +++++

Can you figure something out from this? It looks as if the table is the
issue at this specific part.

--
Peter Karlström
Midrange AB
Sweden
 
J

Jialiang Ge [MSFT]

Thank you very much, Peter. The log information is very helpful to narrow
down our focus. There seem some problems when we format the table. I
queried our internal data base, but unfortunately, I did not find similar
issue reports. My Windows XP + Office XP box cannot reproduce the symptom
either. It's abnormal that table-formatting takes such a long time. Peter,
is it possible for you to format the table in Word directly? Will it hang
when we do it manually? Would you please try the code snippet as a VBA
macro in Word (Alt + F11)? Does it take a long time to run the macro?

Regards,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================
 
P

Peter Karlström

Hi Jialiang Ge

I will visit the customer on tuesday and will se what we can do. The client
we are testing is 400 KM away, so we use Remote Desktop when we test. (She
must be there to authorize it in order for us to test)
If possible we will test the steps manually and in VBA.
I will get back to you with results a.s.a.p.

Best Regards
 
J

Jialiang Ge [MSFT]

Hello Peter,

Here are a couple of other things that deserve your test, though they are
not necessarily related to this issue.

1. Try changing the default printer to a local one.
2. What happens if we start Word in safe mode (winword.exe /safe), and run
the code snippet as a macro?

Regards,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================
 
P

Peter Karlström

Hi Jialiang Ge

The tests are not likely to be made until next week due to "human resources".
When the tests have been made, is it OK if we mail the logging, the template
file and the VBA-document to you?

Regards
 
J

Jialiang Ge [MSFT]

Sure, Peter. You are welcome to send them to me. It's my pleasure to look
into it for you. My email address can be found in my signature.

Regards,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top