none
How to set WdViewType for a document and NOT affect subsequent documents? RRS feed

  • Question

  • I'm creating an application that exports to Word 2010.

    We want that document to be WdViewType.wdWebView.

    No problem! In my export function either:

    doc.ActiveWindow.View.Type = WdViewType.wdWebView;

    or

    doc.Windows.get_Item(objIndex).View.Type = WdViewType.wdWebView;

    will work fine. But how can I restore the original view for subsequent docs? I can store the original view but there's no obvious place to set it. The 'View.Type' value is on either the active Window or a specific Window from the windows collection. Setting the ActiveWindow view reverts the current document that I've just created to the original view... so I can't do that.

    I've explored creating another empty document and setting its View. But that only works for new docs created from that new window. If the user tabs back to the still open doc with a WebView any newly created docs from that window will also be WebView


    Monday, June 17, 2013 1:38 PM

Answers

  • This is the way Word was designed to work: it takes the default view settings from the currently active document when the user creates a default new document.

    About the only thing you could do would be to have your application, or an add-in, monitor the NewDocument event to change the view when a new document is created...


    Cindy Meister, VSTO/Word MVP, my blog

    Monday, June 17, 2013 3:02 PM
    Moderator