Microsoft Word - Slow speed of VBA macros written for Word 2003 in 2007/2010

Asked By John Davidson on 09-Mar-11 01:03 AM
There's been a fair amount of online comment, on this site and elsewhere, on the painfully slow execution of VBA macros for Word and Excel. Only a few users seem to have solved their problem, particularly Excel users (see http://www.eggheadcafe.com/software/aspnet/31757122/2007-macros-painfully-slow.aspx), I have a suite of macros written for me by someone who is no longer available for lengthy consultation. They search a large number of Word documents, and extract passages according to the occurence of user defined strings. The bulk of the runtime programming is dealing with search and extract sequences, one file after the other.

In Word 2007/2010, running in compatability mode, it runs about 5 times slower than in 2003. Since a longish run can take 5-10 mins even in Word 2003, a runtime of 30-60 mins in  2007/2010 is unacceptable.

Has this issue been resolved? Does anyone know why this happens, and what can be done about it? I've searched the MS support pages, and found nothing relevant. Obvious things like switching off screen-updating have been attended to. What is different about the way Word 2007/2010 handles VBA macros and text to the way they are handled in 2003, that would make such a big speed difference? Is it simply that Word's internal handling of text in .docx (=.xml) format is slower, and nothing can be done about it?

Presently, the best solution is to have a copy of 2003 running on the same computer, but not all the users of this macro suite have Word 2003. And with users of 2007, the continuous reconfiguration of 2007 to/from 2003 (which takes 5 mins or more), is a real nuisance.

Any helpful ideas would be much appreciated.

John Davidson
James Murray replied to John Davidson on 09-Mar-11 12:45 PM
Hello John,

Our school district technology department went from XP machines to win7 and also switched over from office 2003 to office 2010.

As the database manager, I use excel frequently for manipulating data between different sources. All my VBA macros have worked fine without any slowness since switching to excel 2010.

However, I also re-saved my workbooks as 2010's .xlsm format (excel with macros) and turned off macro security completely.

Have you converted (saved) your workbooks and documents in the recommend .xlsm (excel macro enabled workbook) and .docm (Word Macro Enabled Workbook) formats and tested their performance and/or functionality in the new formats?

When you are in a .doc and you save it as a .docm, it produces a second file as it cannot over a .doc with a .docm.

Try it, let us know of your results. You may be able to avoid the pain of compatibility mode completely and simply upgrade your files.
John Davidson replied to James Murray on 14-Mar-11 08:35 AM

 

Hello James -- Thanks for your input and my apologies for the delay in getting back to you. We have been completing some speed tests. It seems that dealing with Word 2010 .docx format files (=compressed xml files - you can open them in WinZip) is slower whatever you do. Even when reading .docx files, and doing nothing at all to them, takes 9 times longer in Word 2010 than in Word 2003. We have tried switching off all anti-virus checking, checked the default printer to be local, and that our test computer is not and never has been connected to a network. Nor are there are any damaged or unavailable fonts. We have also removed all Word startup templates, and forced Word 2010 to create a new normal.dot. (These are all things recommended by MS). Word still takes longer to open a file (.doc or .docx) in Word 2010 than in 2003. This makes a difference when reading and processing several hundred files. Also, OurMacros (text search/manipulation/extraction) itself runs significantly slower in Word 2010 than in Word 2003.

Having converted OurMacros.dot to OurMacros.dotm (for Word 2010), here's what we did:

Summary (running OurMacros on a collection of 155 Word files):

* Simply reading files under Word 2010 (reading .doc files) is around 2.5 times slower than Word 2003 (reading .doc files)(94 secs vs. 38 secs). This was done with a macro that reads in files, does nothing to them, and then moves on to the next file in the folder.

* Simply reading files under Word 2010 (reading .docx files) is around 9 times slower than Word 2003 (reading .doc files) (331 secs vs. 38 secs). This was done as above.

* Running OurMacros under Word 2010 (reading .doc files) is around 3 times slower than Word 2003 (reading .doc files)

* Running OurMacros under Word 2010 (reading .docx files) is around 8 times slower than Word 2003 (reading .doc files)

Therefore:

1. Both reading files and actually running OurMacros are slowed down by roughly the same amount when running under Word 2010.

2. In Word 2010, it's marginally faster to run OurMacros in non-compatability mode, but working on .doc rather than .docx files is faster.

3. Given a choice (in our instance), use of Word 2003 is always much faster than Word 2010.

4. Using .docx files as opposed to .doc files slows down both file reading and running of OurMacros.

Unless there is something that can be done to reduce the time taken by Word 2010 to read in files (.docx or .doc),

I suspect that we have resolved at least part of the mystery, but can do nothing about it. Why OurMacros should run slower under Word 2010 than Word 2003 remains a mystery, but it is noteworthy that the actual speed difference depends on whether you start with .doc or .docm files.

The data for a modest run of OurMacros on 155 files (111MB in .doc/ 56.5MB .docx, compressed):

 

   Word 2003   Word 2010   Word 2003    Word 2010    Word 2010

   Read files    Read files  Run OurMacros    Run OurMacros    Run OurMacros

  Non-comp.        Non-comp.    Comp

 

.doc   38 secs    94 secs    79 secs (= 38 + 22)  216 ( 94 + 122)   209 secs

.docx  374 secs  331 secs    396 secs (=374 + 41) 647 (331 + 316)   685 secs

(My neat little table of data from Word refuses to behave, :-) but follow the colours and it should be clear enough!)

Our solution: To avoid long delays when running OurMacros, run Word 2003 along with Word 2010, either alongside it or in a virtual PC environment.


Any suggestions or explanations of what's going on would be much appreciated!

 

James Murray replied to John Davidson on 14-Mar-11 03:16 PM
Hey John,

Thank you for the very thorough explanation.

If you could provide:

1. The code your macros are using to find/open/read the .docx files.
2. Provide the references (libraries) your code is using to connect to the files.

Some more questions...

Will it be required to read a mixed amount of formats (2003 and 2010)?

Or once you work out the issues with 2010 will all the files be 2010 format?

Proposed Resolution:

I believe we need to update your macro code to treat docx files as xml format or as docx in the macro code. Being that its XML data and not HTML data, if your macro code was altered to treat docx files as XML data or a DOCX format your read speeds would be immensely faster than your Word 2003 results as XML can be indexed and read with greater proficiency.

As it stands now, when you are reading docx files its converting from XML to HTML and then performing your "read" or "finds" in the file. Its obvious this is very inefficient.

I don't believe there is any conversion fix other than altering your code which I'm more than happy to take a look at.


John Davidson replied to James Murray on 14-Mar-11 11:09 PM

Hi James - I spoke to the friend who wrote the software and he replies:

A list of document names is obtained by using a "Scripting.FileSystemObject" to recursively read control files (i.e. simple text files) that contain the names of documents to be searched.

For each document name, a check is performed to ensure that the document actually exists (using a "Scripting.FileSystemObject").

Then, if it isn't already open in Word, it is opened using the following statement :

Set OpenSearchableDocument = Documents.Open(FileName:=p_strFullname, ConfirmConversions:=False, ReadOnly:=True, AddToRecentFiles:=False, Revert:=False, Visible:=False)

(Since a Format parameter isn't specified, the document's existing format is used).

Searches are then performed for input strings essentially using statements like this :

    Set rng = p_doc.range(Start:=lngCharStart, End:=lngCharEnd)
    With rng.Find
    .ClearFormatting
    .MatchWholeWord = mSearchParams.IsMatchWholeWord
    .MatchCase = mSearchParams.IsCaseSensitive
    .MatchAllWordForms = p_searchPosn.mIsMatchAllWordForms
    .Wrap = wdFindStop
    .Forward = True
    .Text = p_searchPosn.mSearchString
    .Highlight = False
   
    ' If string not found, note that the search has ended, and exit
    If .Execute = False Then
    p_searchPosn.ResetWorkAttributes
    p_searchPosn.mHasSearchEnded = True
    Exit Sub
    End If
    End With
  
These are the referenced libraries :

Visual Basic for Applications

Microsoft Word 12.0 Object Library

OLE automation

Microsoft Office 12.0 Object Library

Microsoft Forms 2.0 Object Library

Microsoft Visual Basic for Applications Extensibility 5.3

You also ask whether we will move entirely to Word 2010 if/when the speed issues are resolved. The answer is that our system is run on individual personal computers, in various places around the world, and it depends on what each person wants to use. We would therefore have two versions of the macros, and if necessary, two versions of the Word files comprising the database. One for Word 2003 and one for Word 2007/2010.

Thanks very much for your help. Let me know if you need any other information.

John



James Murray replied to John Davidson on 15-Mar-11 01:37 AM
Hey John,

The code looks compatible with the Word 2010 interop library.

The most simple solution and the first thing I would try is changing the references from:

Microsoft Word 12.0 Object Library      (Word 2003)
Microsoft Office 12.0 Object Library      (Office 2003)

To:

Microsoft Word 14.0 Object Library      (Word 2010)
Microsoft Office 14.0 Object Library      (Office 2010)






Lets start with that and move on from there.

Lets see if it speeds up the process, or blows up your code (both things are good).

If it works, great. If it errors, at least we know the new library code has significant changes, and may just need more tweaking. The worst thing that could happen is that it does nothing.

John Davidson replied to James Murray on 15-Mar-11 02:40 AM
Hi James

Thanks again - I'll ask my friend to do as you ask, though it may be a few days before he gets back to me/us.

John

John Davidson replied to James Murray on 16-Mar-11 10:41 AM
Hello James

Attached you'll find (I hope) a macro (RunMacroAgainstManyDocs - it seems to have gone into in the Image Upload Manager folder - the Zip File Upload Manager had no upload buttons) that simply reads in files sequentially and runs a named macro. Useful for performing the same operation on a collection of files/folders. To get the basic timings for just reading files only, I ran RunMacroAgainstMany Docs using NullMacro, which effectively does nothing, viz:

Sub NullMacro()
    Selection.HomeKey Unit:=wdStory
End Sub

As you can see from my results, Word 2010 was taking around 2 secs simply to read a .docx file, which - when multplied by several hundred - becomes a significant time in itself. When reading in the file, the message "Validating ... (something)" flashed up on the status bar, but too quickly to read what it said.

We seem to have two problems - slow file-reading and slow macro execution. If we resolve the first problem, we may automatically resolve the second. At least, with the attached macro, you can take a collection of .docx Word files and see how long it takes to read them and do nothing to them. The average size of our .doc files on our test run was around 715KB.

When running RunMacroAgainstManyFiles, deselect all options except
 
> Open the document before running the macro
> Make the document the active document before running the macro
> Stop further calls to the Macro after the first error is encountered
 
To run on .doc files only, select Only Documents
To run on .docx files, deselect Only Documents

I'll be interested to see if you can reproduce our timings.

Thanks again for your help, and at least you and other visitors to the forum will get a useful little macro from our dialogue (if I've managed to upload it correctly ... I can see it when editing, but not in the final post)!

John


James Murray replied to John Davidson on 16-Mar-11 11:25 AM
Hey John,

I do not see the file attached or linked to your post.

Can you please retry to attach the file or email to my email address jamesmurrayga@hotmail.com
John Davidson replied to James Murray on 16-Mar-11 11:36 AM
I've tried again, and also emailed it.

BTW, 2010 is already using the 14.0 Object Library without needing to be told to do so (regardless of whether running OurMacros.dot or .docm.

RunMacroAgainstManyDocs.Zip

J.
James Murray replied to John Davidson on 16-Mar-11 12:54 PM
Hey John,

I'm actually getting the same results when running the macro on Word 2010 formats in comparison to Word 2003.

I'm throwing in some prompts to the code so I can get the flow how the macro is calling its functions. Being there is a form that loads at the beginning it makes it troublesome to "step into" for debugging.

I'll let you know what I find shortly.
James Murray replied to James Murray on 17-Mar-11 12:38 PM
Hey John,

Ok, so my slowness yesterday was from the fact that the two .docx files I had in my .docx list were 5 and 10 megs filled with screen captures.

I tried it again by using a 100kb .doc and .docx files and the speed of them were exactly the same.

150 .doc files took 100seconds to open.
150 .docx files took 102seconds to open.

Now, I have been getting an error after the macro opens the word document and attempts to find a string.

Error while running macro against document C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\Mydocument.docx. Object doesn't support this property or method

This happens for .doc as well and I have security disabled for all macros.

I'm running the macro

Repeat Macro version  : 1.0.0
Macro container     : RunMacroAgainstManyDocs.dot
Microsoft Word build  : 14.0.5123
Operating System    : Windows NT 6.1
 
3/16/2011 12:06:05 PM : 0 secs : Settings
3/16/2011 12:06:05 PM : 0 secs : ----------------------------------------
3/16/2011 12:06:05 PM : 0 secs : Macro        : Normal.Module1.Main
3/16/2011 12:06:05 PM : 0 secs : Open document    : True
3/16/2011 12:06:05 PM : 0 secs : Activate document  : True
3/16/2011 12:06:05 PM : 0 secs : Save document    : False
3/16/2011 12:06:05 PM : 0 secs : SaveAs document    : False
3/16/2011 12:06:05 PM : 0 secs : Pass parameter1    : True
3/16/2011 12:06:05 PM : 0 secs : Pass parameter2    : True
3/16/2011 12:06:05 PM : 0 secs : Parameter2     : mystring
3/16/2011 12:06:05 PM : 0 secs : Stop on 1st error  : False

If this is a common error and I'm not using the macro right and we can resolve it, I can continue testing...

If its not, I'll start finding out why I'm getting it.

I'd thought I'd throw the error at you and see if you've seen it before I throw it at you before I attempt to fix it myself.




John Davidson replied to James Murray on 17-Mar-11 07:05 PM
Hi James

Just to check that I understand ... you have run RunMacroAgainstManyDocs using a NullMacro of some sort, and it completes OK. Then you change the NullMacro to a macro that tries to find a string and you get an error - ??

I've never had such an error, and will ask the writer of the programme. Have you have ticked the relevant boxes in the RunMacroAgainstManyDocs userform as per my post of 16-Mar-11 10:41 AM?

However, in our tests, with Word 2003, it takes only 38 secs to open 156 .doc files, 111MB total, and it takes Word 2010 94 secs to open the same .doc files. But it takes Word 2010, 331 secs to open the same files in .docx format.

So to some extent you have been able to repeat our timings, and demonstrate the slowness of Word 2010. In fact, your 150 x 100KB files only come to 15MB (which you opened in 100 secs), while we were opening 156 files totalling 111MB, so you are getting much much slower speeds even than us. Have you got your files on your local hardrive or on the network? Is your Word 2010 on the network or on your local harddrive? I wonder if we are comparing like with like here. Network access can slow things down.

Are you getting the timings from the end of the logfile produced by RunMacroAgainstManyDocs, or are you doing manual timings (which would add in all sorts of non-runtime overheads)


John
James Murray replied to John Davidson on 17-Mar-11 07:54 PM
I figured it out. I had the null macro in the wrong spot.

The difference in the time it takes to open

DOCX Test

This file can be located at : C:\Users\jmurray\AppData\Local\Temp\QF_6B39.tmp
---------------------------------------------------------------------------
Repeat Macro version  : 1.0.0
Macro container     : RunMacroAgainstManyDocs.dot
Microsoft Word build  : 14.0.5123
Operating System    : Windows NT 6.1
 
3/17/2011 4:27:35 PM : 0 secs : Settings
3/17/2011 4:27:35 PM : 0 secs : ----------------------------------------
3/17/2011 4:27:35 PM : 0 secs : Macro        : Normal.NewMacros.NullMacro
3/17/2011 4:27:35 PM : 0 secs : Open document    : True
3/17/2011 4:27:35 PM : 0 secs : Activate document  : True
3/17/2011 4:27:35 PM : 0 secs : Save document    : True
3/17/2011 4:27:35 PM : 0 secs : SaveAs document    : False
3/17/2011 4:27:35 PM : 0 secs : Pass parameter1    : False
3/17/2011 4:27:35 PM : 0 secs : Stop on 1st error  : False
3/17/2011 4:27:35 PM : 0 secs :  
3/17/2011 4:27:35 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (5).docx
3/17/2011 4:27:35 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (62).docx
3/17/2011 4:27:35 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (69).docx
3/17/2011 4:27:36 PM : 1 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (31).docx
3/17/2011 4:27:36 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (85).docx
3/17/2011 4:27:36 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (8).docx
3/17/2011 4:27:37 PM : 1 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (49).docx
3/17/2011 4:27:37 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (23).docx
3/17/2011 4:27:37 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (75).docx
3/17/2011 4:27:37 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (64).docx
3/17/2011 4:27:38 PM : 1 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (13).docx
3/17/2011 4:27:38 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (80).docx
3/17/2011 4:27:38 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (44).docx
3/17/2011 4:27:39 PM : 1 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (41).docx
3/17/2011 4:27:39 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (10).docx
3/17/2011 4:27:39 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (34).docx
3/17/2011 4:27:40 PM : 1 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (77).docx
3/17/2011 4:27:40 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (20).docx
3/17/2011 4:27:40 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (25).docx
3/17/2011 4:27:40 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (78).docx
3/17/2011 4:27:41 PM : 1 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (79).docx
3/17/2011 4:27:41 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (55).docx
3/17/2011 4:27:41 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (30).docx
3/17/2011 4:27:42 PM : 1 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (56).docx
3/17/2011 4:27:42 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (45).docx
3/17/2011 4:27:42 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (76).docx
3/17/2011 4:27:43 PM : 1 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (35).docx
3/17/2011 4:27:43 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (14).docx
3/17/2011 4:27:43 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (81).docx
3/17/2011 4:27:44 PM : 1 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (68).docx
3/17/2011 4:27:44 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (48).docx
3/17/2011 4:27:44 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (40).docx
3/17/2011 4:27:45 PM : 1 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (84).docx
3/17/2011 4:27:45 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (6).docx
3/17/2011 4:27:45 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (61).docx
3/17/2011 4:27:45 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (24).docx
3/17/2011 4:27:46 PM : 1 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (60).docx
3/17/2011 4:27:46 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (7).docx
3/17/2011 4:27:46 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (71).docx
3/17/2011 4:27:47 PM : 1 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (15).docx
3/17/2011 4:27:47 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (82).docx
3/17/2011 4:27:47 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (29).docx
3/17/2011 4:27:48 PM : 1 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (51).docx
3/17/2011 4:27:48 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (73).docx
3/17/2011 4:27:48 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (72).docx
3/17/2011 4:27:48 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (59).docx
3/17/2011 4:27:49 PM : 1 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (36).docx
3/17/2011 4:27:49 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (26).docx
3/17/2011 4:27:49 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (18).docx
3/17/2011 4:27:50 PM : 1 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (57).docx
3/17/2011 4:27:50 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (54).docx
3/17/2011 4:27:50 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (21).docx
3/17/2011 4:27:51 PM : 1 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (67).docx
3/17/2011 4:27:51 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (33).docx
3/17/2011 4:27:51 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (47).docx
3/17/2011 4:27:51 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (12).docx
3/17/2011 4:27:52 PM : 1 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (66).docx
3/17/2011 4:27:52 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (65).docx
3/17/2011 4:27:52 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (46).docx
3/17/2011 4:27:53 PM : 1 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (11).docx
3/17/2011 4:27:53 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (42).docx
3/17/2011 4:27:53 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (43).docx
3/17/2011 4:27:53 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (32).docx
3/17/2011 4:27:54 PM : 1 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (4).docx
3/17/2011 4:27:54 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (63).docx
3/17/2011 4:27:54 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (22).docx
3/17/2011 4:27:55 PM : 1 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (9).docx
3/17/2011 4:27:55 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (17).docx
3/17/2011 4:27:55 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (27).docx
3/17/2011 4:27:56 PM : 1 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (53).docx
3/17/2011 4:27:56 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (58).docx
3/17/2011 4:27:56 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (70).docx
3/17/2011 4:27:56 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (50).docx
3/17/2011 4:27:57 PM : 1 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (74).docx
3/17/2011 4:27:57 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (37).docx
3/17/2011 4:27:57 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (38).docx
3/17/2011 4:27:58 PM : 1 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (28).docx
3/17/2011 4:27:58 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (83).docx
3/17/2011 4:27:58 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (16).docx
3/17/2011 4:27:59 PM : 1 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (52).docx
3/17/2011 4:27:59 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (39).docx
3/17/2011 4:27:59 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (19).docx
3/17/2011 4:27:59 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc.docx
3/17/2011 4:28:00 PM : 1 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy.docx
3/17/2011 4:28:00 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (2).docx
3/17/2011 4:28:00 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Docx\testdoc - Copy (3).docx
3/17/2011 4:28:01 PM : 1 secs : Total execution time = 26 secs

DOC Test

This file can be located at : C:\Users\jmurray\AppData\Local\Temp\QF_4CE1.tmp
---------------------------------------------------------------------------
Repeat Macro version  : 1.0.0
Macro container     : RunMacroAgainstManyDocs.dot
Microsoft Word build  : 14.0.5123
Operating System    : Windows NT 6.1
 
3/17/2011 4:29:38 PM : 0 secs : Settings
3/17/2011 4:29:38 PM : 0 secs : ----------------------------------------
3/17/2011 4:29:38 PM : 0 secs : Macro        : Normal.NewMacros.NullMacro
3/17/2011 4:29:38 PM : 0 secs : Open document    : True
3/17/2011 4:29:38 PM : 0 secs : Activate document  : True
3/17/2011 4:29:38 PM : 0 secs : Save document    : True
3/17/2011 4:29:38 PM : 0 secs : SaveAs document    : False
3/17/2011 4:29:38 PM : 0 secs : Pass parameter1    : False
3/17/2011 4:29:38 PM : 0 secs : Stop on 1st error  : False
3/17/2011 4:29:38 PM : 0 secs :  
3/17/2011 4:29:38 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (10).doc
3/17/2011 4:29:38 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (11).doc
3/17/2011 4:29:39 PM : 1 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (12).doc
3/17/2011 4:29:39 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (13).doc
3/17/2011 4:29:39 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (14).doc
3/17/2011 4:29:39 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (15).doc
3/17/2011 4:29:40 PM : 1 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (16).doc
3/17/2011 4:29:40 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (17).doc
3/17/2011 4:29:40 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (18).doc
3/17/2011 4:29:40 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (19).doc
3/17/2011 4:29:41 PM : 1 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (2).doc
3/17/2011 4:29:41 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (20).doc
3/17/2011 4:29:41 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (21).doc
3/17/2011 4:29:41 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (22).doc
3/17/2011 4:29:42 PM : 1 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (23).doc
3/17/2011 4:29:42 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (24).doc
3/17/2011 4:29:42 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (25).doc
3/17/2011 4:29:42 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (26).doc
3/17/2011 4:29:43 PM : 1 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (27).doc
3/17/2011 4:29:43 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (28).doc
3/17/2011 4:29:43 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (29).doc
3/17/2011 4:29:43 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (3).doc
3/17/2011 4:29:44 PM : 1 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (30).doc
3/17/2011 4:29:44 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (31).doc
3/17/2011 4:29:44 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (32).doc
3/17/2011 4:29:44 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (33).doc
3/17/2011 4:29:45 PM : 1 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (34).doc
3/17/2011 4:29:45 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (35).doc
3/17/2011 4:29:45 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (36).doc
3/17/2011 4:29:45 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (37).doc
3/17/2011 4:29:46 PM : 1 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (38).doc
3/17/2011 4:29:46 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (39).doc
3/17/2011 4:29:46 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (4).doc
3/17/2011 4:29:46 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (40).doc
3/17/2011 4:29:47 PM : 1 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (41).doc
3/17/2011 4:29:47 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (42).doc
3/17/2011 4:29:47 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (43).doc
3/17/2011 4:29:47 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (44).doc
3/17/2011 4:29:48 PM : 1 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (45).doc
3/17/2011 4:29:48 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (46).doc
3/17/2011 4:29:48 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (47).doc
3/17/2011 4:29:48 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (48).doc
3/17/2011 4:29:49 PM : 1 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (49).doc
3/17/2011 4:29:49 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (5).doc
3/17/2011 4:29:49 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (50).doc
3/17/2011 4:29:49 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (51).doc
3/17/2011 4:29:50 PM : 1 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (52).doc
3/17/2011 4:29:50 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (53).doc
3/17/2011 4:29:50 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (54).doc
3/17/2011 4:29:50 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (55).doc
3/17/2011 4:29:51 PM : 1 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (56).doc
3/17/2011 4:29:51 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (57).doc
3/17/2011 4:29:51 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (58).doc
3/17/2011 4:29:51 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (59).doc
3/17/2011 4:29:52 PM : 1 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (6).doc
3/17/2011 4:29:52 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (60).doc
3/17/2011 4:29:52 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (61).doc
3/17/2011 4:29:52 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (62).doc
3/17/2011 4:29:53 PM : 1 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (63).doc
3/17/2011 4:29:53 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (64).doc
3/17/2011 4:29:53 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (65).doc
3/17/2011 4:29:53 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (66).doc
3/17/2011 4:29:54 PM : 1 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (67).doc
3/17/2011 4:29:54 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (68).doc
3/17/2011 4:29:54 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (69).doc
3/17/2011 4:29:54 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (7).doc
3/17/2011 4:29:55 PM : 1 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (70).doc
3/17/2011 4:29:55 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (71).doc
3/17/2011 4:29:55 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (72).doc
3/17/2011 4:29:55 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (73).doc
3/17/2011 4:29:56 PM : 1 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (74).doc
3/17/2011 4:29:56 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (75).doc
3/17/2011 4:29:56 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (76).doc
3/17/2011 4:29:56 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (77).doc
3/17/2011 4:29:57 PM : 1 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (78).doc
3/17/2011 4:29:57 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (79).doc
3/17/2011 4:29:57 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (8).doc
3/17/2011 4:29:57 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (80).doc
3/17/2011 4:29:58 PM : 1 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (81).doc
3/17/2011 4:29:58 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (82).doc
3/17/2011 4:29:58 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (83).doc
3/17/2011 4:29:59 PM : 1 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (84).doc
3/17/2011 4:29:59 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (85).doc
3/17/2011 4:29:59 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy (9).doc
3/17/2011 4:29:59 PM : 0 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc - Copy.doc
3/17/2011 4:30:00 PM : 1 secs : Running macro against : C:\Users\jmurray\Desktop\TestMacro\Docs\Doc\testdoc.doc
3/17/2011 4:30:00 PM : 0 secs : Total execution time = 22 secs

Keep in mind that my machine is:

Brand new HP Windows 7 64bit with Office 2010 Professional Plus.

I have no other installations of Office on this machine.



Here were my bench mark files

testdoc.zip

If you have a specific macro you want me to test, toss me the code and I will try it.

If you want to know any of my PC specs, programs, ect.

Let me know and I'll be happy to provide them.
James Murray replied to John Davidson on 17-Mar-11 09:38 PM
Hey John,

Using the files you provided me in the email, I'm getting the same issue here.

I'm looking into it.

I'll let you know soon.
John Davidson replied to James Murray on 17-Mar-11 11:16 PM

Hi James

I much appreciate the time you are spending on this.

In case it has any relevance, the files sent to you were originally in WordPerfect 5.1+ (MS-DOS), read into Word 2003, a macro run on them to convert various things like endnotes, fonts, etc., and resaved as .doc files.

Headers and footers, of which there are none in the WP5.1+ files, are still in the HP printer font CG Times 14pt. In fact, only the page numbers are in CG Times, since all other headers and footers were stripped out. But the otherwise blank headers & footers still retain CG Times 14pt as the default font....

... I've just discovered the reason why the headers and footers are still in CG times 14pt. It is because the Normal style has CG Times 14pt as the default font, even tho' the overall document font has been set directly (select all, etc.) to Times New Roman 12pt.

I think it would be worth your while changing Normal style's default font on the test document I sent you to Times New Roman 12pt, and re-creating the .docx file. It may make a difference. Old font formats have been known to cause problems.

J.D.
John Davidson replied to James Murray on 18-Mar-11 10:14 PM
Hi James

A further thought ... In Word 2003, Adobe Acrobat's PDFMaker add-in slows up VBA macros. I could never figure out why. Similar programs such as NitroPDF (Free or Pro) do not have the same drawback. So if you have PDFMaker or other add-ins to Word 2010, they may be causing a slowdown, in addition to whatever else is causing the slow reading of files and execution of macros.

J.D.
John Davidson replied to James Murray on 21-Mar-11 11:12 AM
Just to let you know that resetting the Normal style default font to TimesNewRoman 12pt made no difference to the speed of reading or execution.

J.D.
Bjorn Andre replied to John Davidson on 25-Mar-11 08:55 AM
Hi, nice effort with regards to speeding up macros in Office 2007/2010. We just upgraded from 2003 to 2010 and noe all my macros are running real slow. I did sone tests and my results may shed some light on the problem. I made a real simple macro in excel which just set the background colour in 3 separate cells. The macro also recorded how timeconsuming this operation was. In the beginning I only had ond sheet in my excel workbook and the macro was real quick (0,01sec). The macro was only running in sheet 1. When I added more sheets (with some text and pictures) the macro slowed down. When I had added 15 sheets and the file size was about 1,3Mb the same macro now used approximately 3 seconds to colour the 3 cells. I slowly removed ond by ond sheet and the macro picked up speed. Conlusion: The macro speed is affected by the filesize. Reason unknown! PS: macro security set to low and sheet calculation set to manual, in accordance with other tips out there. Regards BAJohansen
John Davidson replied to Bjorn Andre on 25-Mar-11 10:33 PM

Hi Bjorn - Thanks for the input. Our tests also reveal that both reading files and running text manipulation (search and extract) macros are significantly slower in Word 2007/2010 than 2003, often to the point of unusability. Also, reading and processing .doc files is about 2-3 times slower, while the same with .docx files is 8-9 times slower. Runing in compatability mode seems to slow things down a little.

We haven't noticed any exponential relationship between file size and slow down, but we haven't run any definitive tests on this either. This may be an Excel spreadsheet issue.

It all seems to be something to do with the implementation of the xml file formatting in Office 2007 onwards, and this is effecting even the simplest of one-line programs, as well as more complex macros. Whether there are workarounds, code practices to be avoided etc. that will help a little remains to be seen. James Murray is going to investigate just the file reading side of things. But on evidence gathered so far it seems to me that the problem is intrinsic to the new xml text processing. It would be good to know what the overheads are with xml processing in Office.

MicroSoft seem to be simply ignoring the problem (at least in public), which is unhelpful. I have found nothing significantly useful in their support pages. It reminds me of the switchover from MSDOS to Windows. The early versions of Windows were excessively slow, and it was only resolved by the introduction of faster and faster CPUs. Even now, if you run any MSDOS programs on a modern computer in the virtual DOS machine, they often run significantly faster than the equivalent Windows program (unless they are memory intensive).

Let me know if you have any further insights/information

J.D.



James Murray replied to John Davidson on 30-Mar-11 04:09 PM
Hey John,

I haven't forgotten about ya. Sorry, the runagainstmanydocs form is too large to fit vertically on my laptop's very small vertical resolution screen so I've got to be at one of my PC's to play around with the macro.

I am kind of stumped as well.

What I was hoping to find in the end, was a way to open word 2007/2010 in a minimal mode (safe mode/no proofing) without losing the functionality of accessing the document as a document.

I believe the vast amount of time in the execution of the macro is simply the loading/saving/closing of the document in Word 2007/2010.

The documents.open method simply does not support with specific flags a way to load Word with less plugin support and I even attempted using converters to reduce the time Word 2007/2010 takes to open the document with no luck.

When you simply open Word 2007/2010 you'll notice a quick splash screen and there are ways of executing word to reduce this splash screen by reducing the amount of plugins that start with the program. However, executing this through vba does not seem to be an option unless you want to remove these for all applications.

The last thing I was attempting to do was do this:


Private Sub RunMacro(p_strSourceFullName As String)
 
  On Error GoTo ErrorHandler
  Dim strActivity As String
  Dim doc As Document
  Dim quote As String
   
  quote = Chr(34)
   
  strActivity = ""
  Set doc = Nothing
      
  mMessageRecorder.PrintMessage "Running macro against : " & p_strSourceFullName
 
  ' Open the document
  If chkOpenDoc.Value = True Then
    strActivity = "opening document " & p_strSourceFullName
    Shell ("Winword.exe /q /a /f " & quote & p_strSourceFullName & quote)
    Set doc = Word.Application.Documents.Open(quote & p_strSourceFullName & quote)
     
    If chkActivateDoc.Value = True Then
      strActivity = "activating document " & p_strSourceFullName
      doc.Activate
    End If
  End If


There are so many issues though when you open a document from shell.

However, you can disable the splash screen and remove addons.

The initial issue I encountered is that winword.exe /f opens a file based off the source file and not the original file. /t opens the file but since you have your files password protected it prompts the user if they'd like to continue in read only.

Using sendkeys you may be able to choose that as a default option but sendkeys is buggy.

Truthfully, with the splash screen disabled and addons disabled it still seemed to take a solid second to open/close the word files in 2007/2010.

I dunno, what are your thoughts at this point?
John Davidson replied to James Murray on 30-Mar-11 10:56 PM

Hi James - Thanks for all that testing.

Your results may also explain the reduced speed of macros when some add-ins are present in Word 2003, such as Adobe PDFMaker (but not the NitroPDFMaker equivalent).

Do you think that the add-ins and plug-ins would likewise slow down the speed of execution of text manipulation macros in Word 2007/2010? We have done some timing trials which show that every phase of macro execution is slowed down, but none more so than the opening and reading of files.

BTW, our files are "read-only recommended", not password protected. I never considered that Word's "read-only recommended" option would cause a slowdown. I could run a macro to remove that option from a collection of files, and see what happens. The read-only protection on the file you have been using for testing can be easily removed by copy-pasting the contents into a separate file, and saving it as a new file name, with read-only recommended switched off.

Reduction of the time taken to open a file from 2 secs to 1 second is significant when opening a few hundred files. Your tests also bear out our findings that the decrease in speed seems to bear little or no relationship to the number of characters in a file (= file size, more or less). It's the loading of add-ins and plug-ins that creates the overhead.

Pause for thought, tho' we may have nearly reached the bottom line. ... Three things seem worthwhile:

1. Try things without "read-only recommended" set on our files.

2. Disable the loading of plug-ins at the start of the macro and restore it before exiting.

3. Check whether Word makes an automatic backup of a file that it has just read in - and (if it does) switch off that feature as well for the duration of the macro.

What d'ya think?

JD.

Erik replied to John Davidson on 30-Mar-11 11:34 PM
I'm having the same problems with vba code I wrote for Excel 2003 ... what worked like a charm and is something very basic like hide/show columns takes minutes in Excel 2010 ... it is VERY frustrating.

Erik
John Davidson replied to Erik on 31-Mar-11 01:22 AM

I've just done some trials, and with Word 2003, it makes a huge difference on both file reading (21 secs vs 8 secs in one test) and running a text search/extract macro (119 secs vs 73 secs) if either Word is minimized immediately after starting macro execution, or if another application has the current active window. Worth a try.

One might think that setting ScreenUpdating = False would deal with this, but this is not entirely the case.

JD.