none
Doc having merge fields in header/footer opens in Draft view RRS feed

  • Question

  • I have a doc/dot (or docx/dotx) file, it has merge field in header.

    After the merge fields are updated with values,

    If I call this function to open the document, it opens in draft view rather than print view.

    If there are no merge fields in header/footer, it opens in print view.

    How to set this right, I want the document to open in print view, if there are merge fields in header/footer.

     

     

    CComVariant varFilename(filename);
    CComVariant varReadOnly(readOnly);
    CComVariant varVisible(visible);

    m_pWordDoc = m_pWordApp->Documents->Open(

    &varFilename, // Filename to open
    &m_CovFalse, // Confirm Conversion.
    &varReadOnly, // ReadOnly.
    &m_CovFalse, // AddToRecentFiles.
    &vtMissing, // PasswordDocument.
    &vtMissing, // PasswordTemplate.
    &m_CovTrue, // Revert.
    &vtMissing, // WritePasswordDocument.
    &vtMissing, // WritePasswordTemplate.
    &vtMissing, // Format.
    &vtMissing, // Encoding.
    &varVisible); // Visible.

    Any help will be great.

     

     

     

     

     


    Thanks,
    Saleem

    Wednesday, February 16, 2011 9:22 AM

Answers

All replies

  • Ok, found a work around.

    call this after Open(...);

     

     

    m_pWordApp->ActiveWindow->View->Type = MSWORD::wdPrintView;

    Saleem

    Wednesday, February 16, 2011 12:34 PM
  • Hello Saleem,

    Glad to know that you have worked around this issue. Also thanks very much for coming back and sharing the solution with us. It will probably help other facing the same issue in the forums. Have a nice day.


    Bessie Zhao [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.

    Thursday, February 17, 2011 3:09 AM