Why MS Word Automation is so slow?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9

Thread: Why MS Word Automation is so slow?

  1. #1
    Join Date
    Jan 2003
    Posts
    6

    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.

  2. #2
    Join Date
    Aug 1999
    Location
    <Classified>
    Posts
    6,882
    Because MS WORD is outproc server , and marshalling/demarshaling takes good amount of time.I dont think it can be speeded up.
    Regards,
    Ramkrishna Pawar

  3. #3
    Join Date
    Dec 2001
    Location
    Ontario, Canada
    Posts
    2,236
    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++.

  4. #4
    Join Date
    Aug 1999
    Location
    <Classified>
    Posts
    6,882
    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 ?
    Regards,
    Ramkrishna Pawar

  5. #5
    Join Date
    Jan 2003
    Posts
    6
    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?

  6. #6
    Join Date
    Dec 2001
    Location
    Ontario, Canada
    Posts
    2,236
    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.

  7. #7
    Join Date
    Oct 2000
    Location
    Ottawa, CANADA. (CNADA ROCKS!!)
    Posts
    1,889
    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.

  8. #8
    Join Date
    Oct 2000
    Location
    Ottawa, CANADA. (CNADA ROCKS!!)
    Posts
    1,889
    Krishnaa ..

    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.

  9. #9
    Join Date
    Aug 1999
    Location
    <Classified>
    Posts
    6,882
    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 ???
    Regards,
    Ramkrishna Pawar

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center