C # read/write word: when you are prompted to use Word as the Automation server, you are prompted to save Normal. Dot (exclusive normal. Dot, there is no way to read/write the solution)

Source: Internet
Author: User

For details, when you use word as an Automation server, the system prompts to save Normal. Dot.

Http://support.microsoft.com/kb/285885/zh-cn

 

 

When you automate multiple Microsoft Word instances at the same time, you may receive one or more of the following warnings:

"Normal. dot was being edited by another word session. if you save this document with the original name, you will overwrite any changes made in the other session. do you want to save the document using the original name anyway?" -Or-this file is in use by another application or user. (C: \ Documents ents and Settings \... \ normal. Dot)

If you change the normal. Dot template, these warnings may occur.

Back to Top

Solution

To solve this problem, Perform one of the following operations: Before exiting word or handing over control to the user, set normal. set the saved attribute of the dot template to true, as shown below :...

To solve this problem, Perform one of the following operations:

    • Before exiting word or handing over control to the userSavedSet the property to true, as shown below:

      Application. normaltemplate. Saved = true

      -Or-

    • SetQuitMethodSavechangesParameters are as follows:
      Application. Quit savechanges: = wddonotsavechanges

Back to Top

More information

To reproduce this problem, create a standard EXE project in Visual Basic. By default, form1 is created. On the "project" menu, click "Reference" and add a point...

Steps to reproduce the problem

    1. Create a standard EXE project in Visual Basic. By default, form1 is created.
    2. On the project menu, click reference and add a reference pointing to the version of the Microsoft Word Object Library.
    3. Add a commandbutton control to form1.
    4. Add the following to the form:Code:
      Private sub commandateclick () dim wdapp1 as word. application dim wdapp2 as word. application set wdapp1 = Createobject ("word. application ") wdapp1.visible = true wdapp1.documents. add set wdapp2 = Createobject ("word. application ") wdapp2.visible = true wdapp2.documents. add msgbox "change the default font of document 2. "wdapp2.activedocument. close false wdapp2.quit set wdapp2 = nothing wdapp1.quit set wdapp1 = nothingend sub

    5. Run the Visual Basic Project and click the command button.
    6. A message box appears to instruct you to change the default font of the second document. On the "format" menu, click "font", and then click "default ". If you want to change the default font, click "yes" and then click "OK" to cancel the message box.

When the second word instance is disabled, one of the warnings displayed in the Summary section is displayed.

To solve this problem in the above Code, Perform one of the following operations:

    • Add the following lines before calling the wdapp2.quit method:

      Wdapp2.normaltemplate. Saved = true

      -Or-

    • UseQuitMethodSavechangesParameters are as follows:
      Object saveoption = Microsoft. Office. InterOP. Word. wdsaveoptions. wddonotsavechanges;
      Wa. Quit (ref saveoption, ref missing, ref missing );

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.