none
Word Interop Macro Failure RRS feed

  • Question

  • I am using Word Interop to create a document on the fly and need to do some formatting.  As it turns out using Interop for formatting is like watching grass grow.  I spent days searching for ways to speed it up to no avail. The formatting of lines in  tables is painfully slow.

    Then I had another bright idea.

    Why not embed some macros into the document and run them from interop to see if that would speed things up.  It did! The app performed flawlessly while developing it.

    When I installed the app on the users machine I encountered an issue.  The program crashed when trying to execute the macros.  I slapped a try catch block around the calls to the macros which took care of the program ending.  So now the document is open but none of the macros were run.

    Funny thing is that the macros can be ran manually from the open document.  Any ideas?


    "Those who use Application.DoEvents() have no idea what it does and those who know what it does never use it." - MSDN User JohnWein    Multics - An OS ahead of its time.

    • Moved by Youjun Tang Monday, October 19, 2015 5:27 AM
    Saturday, October 17, 2015 1:52 PM

Answers

  • Hi dbasnett,

    Move to Word for developers forum for a better support, thanks for your understanding :)

    Best Regards,

    Xavier Eoro


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Disagree.

    However, the problem turned out to be a last second, un-tested change to the VB .Net code.  For macros to run Word must be visible and the correct document needs to be the active document.


    "Those who use Application.DoEvents() have no idea what it does and those who know what it does never use it." - MSDN User JohnWein    Multics - An OS ahead of its time.

    • Marked as answer by dbasnett Monday, October 19, 2015 5:34 PM
    Monday, October 19, 2015 5:34 PM

All replies

  • Monday, October 19, 2015 3:16 AM
  • Hi dbasnett,

    Move to Word for developers forum for a better support, thanks for your understanding :)

    Best Regards,

    Xavier Eoro


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, October 19, 2015 5:28 AM
  • Impossible to provide useful suggestions without knowing

    1. The code you're using

    2. The error message that's being generated

    Beyond that, if speed is an issue then you should consider leveraging the Office Open XML file format, generating the document without using the Interop. The Open XML SDK and its Productivity Tool make this relatively "painless".


    Cindy Meister, Office Developer/Word MVP, <a href="http://blogs.msmvps.com/wordmeister"> my blog</a>

    Monday, October 19, 2015 12:58 PM
    Moderator
  • Hi dbasnett,

    Move to Word for developers forum for a better support, thanks for your understanding :)

    Best Regards,

    Xavier Eoro


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Disagree.

    However, the problem turned out to be a last second, un-tested change to the VB .Net code.  For macros to run Word must be visible and the correct document needs to be the active document.


    "Those who use Application.DoEvents() have no idea what it does and those who know what it does never use it." - MSDN User JohnWein    Multics - An OS ahead of its time.

    • Marked as answer by dbasnett Monday, October 19, 2015 5:34 PM
    Monday, October 19, 2015 5:34 PM