none
Word 2010, VBA, Building blocks and SharePoint 2010 no consistent behaviour. RRS feed

  • Question

  • Hello,

    I have a pretty simple question, or at least i thought it was pretty simple.

    I need to create a couple of standard documents that contain standard headers. Now instead of creating a dotx for every document i had the brilliant idea of creating one standard document that can change depending on the users need.

    One thing that is very important is that i don't want anything installed on the user machines. 

    Looking at the buildingblocks ( auto text feature ) in Word 2010 and the option to save them inside the template looked like a good solution.

     

    So went about creating my template:

    Create a blank Dotm.

    Layout the document as needed.

    Inserted the headers that i needed. And saved them to the buildingblock library inside the Template itself.

    Created a content control that a user uses to select the header that he or she needs. The onExit event is used to update the document.

    VBA is used to select and insert the right Buildingblock in the header of the document.

    This seems like nothing out of the ordinary.

    There is just one problem, and it is a pretty big problem actually.

    I just can't seem to get consistent behaviour from Word 2010.

    Sometimes it works as expected:

    I open a document from a document library, select the style i need and the document changes in the style that i need.

    Often it just doesn't change at all. No error, no nothing.

    I open the debugger, don't change a line of code. Close it again and it works!

    Or i put in a breakpoint and step trough the code and it starts working!

    This is very disappointing to say the least. I need this to work as expected and stay working as expected because people will want to use it and frankly i think it is a pretty elegant solution.

    Any ideas why it behaves erratically?

    Regards,

     

    Kor

    Thursday, March 17, 2011 8:34 AM

Answers

  • I think i found it.

     

    Found a post on StackOverflow that guided me in the right direction.

     

    In short: me.method does not equal ActiveDocument.method  :)

     

    Regards,

     

    Kor

    Thursday, March 17, 2011 9:44 AM

All replies

  • I think i found it.

     

    Found a post on StackOverflow that guided me in the right direction.

     

    In short: me.method does not equal ActiveDocument.method  :)

     

    Regards,

     

    Kor

    Thursday, March 17, 2011 9:44 AM
  • Hi Pants79,

    Thanks for posting in the MSDN Forum.

    I’m glad to hear you resolve your issue. Thanks for sharing your experiences here, and it will be very beneficial for other community members who have similar questions to see how you have dealt with your issue.

    Have a great day,

    Tom Xu


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, March 21, 2011 1:35 AM
    Moderator