Hi group

I have a macro that uses the ActiveDocument.Name property, but it seems
that when I create a new document based on the template that holds this
macro, the new document is not always the active document.

I would assume that when you create a new document, this would
automatically be set as the active document, but I can see it happens
many times, that the new document it placed behind one or more documents
currently opened in Word, and one of these is the active document
instead of the newly created one.

How can I force the newly created document always to be the active document?

Best regards
Hans-Henrik

Re: Word 2003 ActiveDocument.Name by David

David
Sun Jun 24 17:25:44 CDT 2007

Dim MyDoc1 As Document

Set MyDoc1 = Documents.Add()

Now, MyDoc1 is set as a object and you can access it without having to
make it active.

Or, if you must have it active, MyDoc1.Activate


Re: Word 2003 ActiveDocument.Name by HHDM

HHDM
Sun Jun 24 23:58:19 CDT 2007

David Sisson skrev:
>
Yes, but this will add an extra document - what I want to do is, make a
new document based on a specifik template, that already contains some
text, and I want the newly created document to be the active one, which
it not always is, as previously described.

If I use Documents.Add() - I'll get an extra document.

I would like to be able to select Files -> New
Then select template and go



>

Re: Word 2003 ActiveDocument.Name by Russ

Russ
Mon Jun 25 02:21:29 CDT 2007

Read this message thread about open document events.
It sounds like you want to put your activate command in the
Document_Open()
ThisDocument.Activate
End Sub
event of the ThisDocument module of the template.
http://tinyurl.com/2zkoax

> David Sisson skrev:
>>
> Yes, but this will add an extra document - what I want to do is, make a
> new document based on a specifik template, that already contains some
> text, and I want the newly created document to be the active one, which
> it not always is, as previously described.
>
> If I use Documents.Add() - I'll get an extra document.
>
> I would like to be able to select Files -> New
> Then select template and go
>
>
>
>>

--
Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID


Re: Word 2003 ActiveDocument.Name by Doug

Doug
Mon Jun 25 04:17:55 CDT 2007

Take the time to look at the .Add function for the Document object in the
Visual Basic Help File and all will be revealed.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"HHDM" <hhdm@hotmail.com> wrote in message
news:%23V%23ZuVutHHA.2124@TK2MSFTNGP02.phx.gbl...
> David Sisson skrev:
>>
> Yes, but this will add an extra document - what I want to do is, make a
> new document based on a specifik template, that already contains some
> text, and I want the newly created document to be the active one, which it
> not always is, as previously described.
>
> If I use Documents.Add() - I'll get an extra document.
>
> I would like to be able to select Files -> New
> Then select template and go
>
>
>
>>



Re: Word 2003 ActiveDocument.Name by HHDM

HHDM
Mon Jun 25 13:29:10 CDT 2007

Thanks Russ

You got me on the right track

I now use the Document_New()

then use a public variable:

documentname = ActiveDocument.Name

and I can then use Documents(documentname).Activate where appropriate