January 22nd, 2003, 02:10 AM
Why MS Word Automation is so slow?
In my project I adopted OLE Automation to access MS Word. The performance is disappointing. Even a single operation to get a _Document object or get a selected segment takes over 10 milliseconds. Why it's so slow? Is there any way to speed it up? Any hints will be very grateful.
January 22nd, 2003, 02:19 AM
Because MS WORD is outproc server , and marshalling/demarshaling takes good amount of time.I dont think it can be speeded up.
January 22nd, 2003, 08:19 AM
It is faster if you control if from vb, but I agree with you, it is way too slow. I hate debugging it, because it takes so long to run through the code. I just end up writing all my code in VBA and translating into c++.
January 22nd, 2003, 08:37 AM
Why it's fast from VB ??? I dont see any reason of diff. between controling it from any kind of executable ... Do anybody else has better reason for this ?
January 22nd, 2003, 04:37 PM
Thanx for commenting.
I acknowledge that the invoking process is rather time consuming, but it seems that this time is far from my test result. I found from a Visual C++ manual book that an invoking for IDispatch takes about 0.5 milliseconds, while in my program the invoking takes as long as over 10 milliseconds. Apart from the time taken by invoking, where has the remained time gone?
January 22nd, 2003, 05:07 PM
I don't know why, but VB is faster for office automation, always. VBA is even faster, because it is the macro editor built into word. Maybe ms optimizes it for vb, I don't know. I can tell you though, I have done a lot of office automation, mainly outlook, but some word and excel from c++ and 10ms is average time to execute any operation.
January 22nd, 2003, 09:13 PM
I posted this reply before I have no Idead what hapended.
Yes invoke calls are costly.
use #import directive to import word's com lib to your project.
use applications setVisible property to off untill you need to show the results to the user. this speeds up things drastically.
January 22nd, 2003, 09:23 PM
I think VB is faster. cause word understands vb natively.
WordBasic (allmost VB) was the language that word unedrstands before it understand C++ ( word 95).
I don't have a real explanation but I think a vb interperter is built into word. c++ calls go through a layer that gets translated to VB.
in other words, for word C++ is 4 th gl and VB is 3 rd gl.
I could be wrong about the explanation; but it is faster to use VB, I know that much.
January 22nd, 2003, 09:45 PM
The time told in MS Manuals is at ideal conditions and on standard PC they tested. On your system it takes 10 ms then it's std. time on your system , or you have slower CPU or fragmentation might be problem.
Hey come on boys , VB , WORD all these are outproc server's , so there is no diff. when they are invoked from diff. applications.
Realy , .. And if it's realy fast with VB programs then it might be VB compilers optimization.
Actualy the things must be slow with VB , because each function call to OS is made in stack of 3-4 internal functions with many validations and parameter conversions.
Have anybody tested VB programs using profiling the time taken to create object of WORD or like that ???
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!