1

Topic: How to close a file through VBA

It is necessary to close before master code performance two files word, for example test1 and test2
Without saving
How it to make?

2

Re: How to close a file through VBA

Document.close?
https://msdn.microsoft.com/en-us/vba/wo … ethod-word

3

Re: How to close a file through VBA

And it will be possible simply which to work an example where it will simply be closed  a file

4

Re: How to close a file through VBA

SAS2014, and who opens these files? Other application? If so - that FindWindow + TerminateProcess.

5

Re: How to close a file through VBA

Akina wrote:

SAS2014 and who opens these files? Other application? If so - that FindWindow + TerminateProcess.

The logic such that in excel is formed the table, further after . Editing by macroes outswapping of tables in word a file (template) that there were no errors of type is fulfilled there are no rights to discoveries that the file is opened already, I want to make so that the macro closes opened word a file, and further already again as is described above

6

Re: How to close a file through VBA

SAS2014 wrote:

that there were no errors of type there are no rights to discoveries that the file is opened already, I want to make so that the macro closes opened word a file, both further

And further the user finds out that edited by it after the previous formation the file was closed without saving,  two hours of hemorrhoids, and starts to spoil a karma of the developer unprintable expressions. It is necessary to you?
Process an open error and if it arises - deduce the message that "it is probable, the template file is already opened, switch in MS Word and close a file. <To continue, interrupt>". And further let the user himself is raked...

7

Re: How to close a file through VBA

Akina wrote:

it is passed...
And further the user finds out that edited by it after the previous formation the file was closed without saving,  two hours of hemorrhoids, and starts to spoil a karma of the developer unprintable expressions. It is necessary to you?
Process an open error and if it arises - deduce the message that "it is probable, the template file is already opened, switch in MS Word and close a file. <To continue, interrupt>". And further let the user himself is raked...

well if on  that yes is possible so

8

Re: How to close a file through VBA

The question is solved, the exception handler used