How to load a new Word document in the same Word window?

It seems that in the Microsoft Word object model, a Word document is tied to a window, but I want to close an existing document and open a new one without closing the Word window. How can i do this?

+1
source share
7 answers

This works for me to close the document and open the document in the same window (I run the macro from normal.dotm):

Sub CloseOpenSameWindow() Dim d As Document: Set d = ActiveDocument Application.ScreenUpdating = False d.Close Application.Documents.Add Template:="C:\Users\Me\Desktop\Mydocument.docx" Application.ScreenUpdating = True End Sub 
+1
source

Have you tried File-> Close? This should close the file and leave the window open, which will allow you to open another file in the same window, at least as I remember how it works.

0
source

Ctrl + w (to close the current window), and then Ctrl + n (to open a new one)

Two key keys, that's all :)

0
source

Isn't that .close?

.exit shutting down the entire application?

0
source

Temporarily use

 Application.ShowWindowsInTaskbar = False 

What Word does effectively in an MDI style application.

0
source

To implement an add-in :

You must consider the following:
  • The add-in should not depend on the window mode (SDI or MDI)
  • The add-in state must be saved to save user settings. Saving add-in state can be achieved using XML, the registry, INI, or any other format.
  • Each time a document is opened, the add-in must change to reflect the state of the document.
  • The add-in must support multiple instances of a Word document.

Cm:

http://www.visualstudiodev.com/visual-studio-tools-for-office/word-addin-multiple-instances-of-word-running-48076.shtml

http://msdn.microsoft.com/en-us/library/aa189710 (v = office.10) .aspx

0
source

try it

in Normal.ThisDocument

 Sub main() Me.Close Documents.Add End Sub 

this will close the current document and open a new document. you need to handle the save for the current document

0
source

Source: https://habr.com/ru/post/1337006/


All Articles