Hi,

I'm trying to close the current instance of Word 03 without affecting any
other open instances.

So far I've got

ActiveDocument.Close savechanges:=wdSaveChanges

but that only closes the document, leaving the application window still
open.

Obviously I have Word set to the (more or less) equivalent of classic MDI,
each instance in its own window.

Any help would be appreciated.

Thanks and BW,
p.

Re: Closing current instance of Word 2003 by Perry

Perry
Sun Mar 11 09:05:50 CDT 2007

> Obviously I have Word set to the (more or less) equivalent of classic MDI,
> each instance in its own window.

If you´ve coded correctly, you can quit each object variable pointing to a
newly created
Word instance seperately.

This is a sequence within Word VBA (!) examplifying object orientated coding
in which
each instance can be addressed seperately and in yr case: killed seperately:
(actually a bit of "inter appliation" automation ... oops that didn't sound
too good, now did it? ....)

Dim Inst1 As New Word.Application
Dim Inst2 As New Word.Application
Dim Doc1 As Document
Dim Doc2 As Document

Inst1.Visible = True
Inst2.Visible = True

Set Doc1 = Inst1.Documents.Add
Set Doc2 = Inst2.Documents.Add

Doc1.Windows(1).Visible = True
Doc2.Windows(1).Visible = True

Doc1.Range(0, 0).InsertAfter "text in doc1"
Doc2.Range(0, 0).InsertAfter "text in doc2"

Doc1.Close 0
Inst1.Quit: Set Inst1 = Nothing

'Now all actions of Inst1 are processed, leaving you Inst2 with document and
the text to proof this.
' Note: all other previsouly instances of Word should be intact as well !

--
Krgrds,
Perry

System:
Vista/Office Ultimate
VS2005/VSTO2005 SE



"Paul B" <pb_publicR.e.m.o.v.e@operamail.com> schreef in bericht
news:13nrdnvfcvlv3.dlg@pbpublic.invalid...
> Hi,
>
> I'm trying to close the current instance of Word 03 without affecting any
> other open instances.
>
> So far I've got
>
> ActiveDocument.Close savechanges:=wdSaveChanges
>
> but that only closes the document, leaving the application window still
> open.
>
> Obviously I have Word set to the (more or less) equivalent of classic MDI,
> each instance in its own window.
>
> Any help would be appreciated.
>
> Thanks and BW,
> p.


Re: Closing current instance of Word 2003 by Paul

Paul
Sun Mar 11 10:54:44 CDT 2007

On Sun, 11 Mar 2007 15:05:50 +0100, Perry wrote:

>> Obviously I have Word set to the (more or less) equivalent of classic MDI,
>> each instance in its own window.
>
> If you´ve coded correctly, you can quit each object variable pointing to a
> newly created
> Word instance seperately.
>
> This is a sequence within Word VBA (!) examplifying object orientated coding
> in which
> each instance can be addressed seperately and in yr case: killed seperately:
> (actually a bit of "inter appliation" automation ... oops that didn't sound
> too good, now did it? ....)
>
> Dim Inst1 As New Word.Application
> Dim Inst2 As New Word.Application
> Dim Doc1 As Document
> Dim Doc2 As Document
>
> Inst1.Visible = True
> Inst2.Visible = True
>
> Set Doc1 = Inst1.Documents.Add
> Set Doc2 = Inst2.Documents.Add
>
> Doc1.Windows(1).Visible = True
> Doc2.Windows(1).Visible = True
>
> Doc1.Range(0, 0).InsertAfter "text in doc1"
> Doc2.Range(0, 0).InsertAfter "text in doc2"
>
> Doc1.Close 0
> Inst1.Quit: Set Inst1 = Nothing
>
> 'Now all actions of Inst1 are processed, leaving you Inst2 with document and
> the text to proof this.
> ' Note: all other previsouly instances of Word should be intact as well !


Thanks, Perry. Definitely a keeper for its depth of insight.

I thought I figured out an easy way to do what I need via SendKeys:

Sub SaveClose()
' Save and Close doc NOW; 03/10/07
ActiveDocument.Close savechanges:=wdSaveChanges
SendKeys "%{f4}"
End Sub

However I then noticed a strange side effect - executing the macro turns
off NumLock! Bizarre.

I'll try later to see if I can salvage my idea or incorporate yours.

Thanks and BW,
p.

Re: Closing current instance of Word 2003 by Tony

Tony
Sun Mar 18 13:42:07 CDT 2007

I believe ...

Application.Quit

... is probably the line of code you are looking for.

--
Enjoy,
Tony

"Paul B" <pb_publicR.e.m.o.v.e@operamail.com> schreef in bericht
news:13nrdnvfcvlv3.dlg@pbpublic.invalid...
> Hi,
>
> I'm trying to close the current instance of Word 03 without affecting any
> other open instances.
>
> So far I've got
>
> ActiveDocument.Close savechanges:=wdSaveChanges
>
> but that only closes the document, leaving the application window still
> open.
>
> Obviously I have Word set to the (more or less) equivalent of classic MDI,
> each instance in its own window.
>
> Any help would be appreciated.
>
> Thanks and BW,
> p.


Re: Closing current instance of Word 2003 by Paul

Paul
Sun Mar 18 14:44:14 CDT 2007

On Sun, 18 Mar 2007 18:42:07 -0000, Tony Jollans wrote:

> I believe ...
>
> Application.Quit
>
> ... is probably the line of code you are looking for.

That is perfect. Thanks much.

paul
--
Using Office 2003 on Windows XP Home