Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / June 2007

Tip: Looking for answers? Try searching our database.

Word 2003 ActiveDocument.Name

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
HHDM - 24 Jun 2007 21:32 GMT
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
David Sisson - 24 Jun 2007 23:25 GMT
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
HHDM - 25 Jun 2007 05:58 GMT
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 - 25 Jun 2007 08:21 GMT
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:
>>
[quoted text clipped - 7 lines]
> I would like to be able to select Files -> New
> Then select template and go

Signature

Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID

HHDM - 25 Jun 2007 19:29 GMT
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
Doug Robbins - Word MVP - 25 Jun 2007 10:17 GMT
Take the time to look at the .Add function for the Document object in the
Visual Basic Help File and all will be revealed.

Signature

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

> David Sisson skrev:
>>
[quoted text clipped - 7 lines]
> I would like to be able to select Files -> New
> Then select template and go
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.