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 / March 2005

Tip: Looking for answers? Try searching our database.

Can I control the sequence of Word document windows?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
headly - 06 Mar 2005 17:41 GMT
Writing some code where a template opens another template to share data from
forms. It's easy to control window activation when you know there are only
two windows open. But when I try to capture the number of open windows and
work from there, I noticed that word will alphabetize the list of windows. So
if my template creates documents1 and documents2, i'm okay if there are no
other windows open. If other windows are open and they have names from
e-zdocument, it throws off my window counting against words alphabetical
window sequencing. Ideas?
Perry - 06 Mar 2005 21:02 GMT
To activate a document from within code, I wouldn't use the Windows()
function to return
a particular document.

I would use object variables of documents you instantiated in code, like:

Dim oDoc_Offer As Word.Document
Dim oDoc_Finalize As Word.Document
Dim oDoc_Invoice As Word.Document

Set oDoc_Offer = Documents.Add("c:\MyPath\Offer.dot")
Set oDoc_Finalize = Documents.Add("c:\MyPath\Finalize.dot")
Set oDoc_Invoice = Documents.Add("c:\MyPath\Invoice.dot")

oDoc_Finalize.Activate
'regardless how many windows are open, the correct document will be
activated
'without having to run/loop through the windows collection...

Krgrds,
Perry

> Writing some code where a template opens another template to share data from
> forms. It's easy to control window activation when you know there are only
[quoted text clipped - 4 lines]
> e-zdocument, it throws off my window counting against words alphabetical
> window sequencing. Ideas?
headly - 06 Mar 2005 23:47 GMT
Thanks for your thoughts Perry. I can see how this can help in one subroutine
but after the documents are open, how do I tell other subroutines in my
module about those object declarations?

> To activate a document from within code, I wouldn't use the Windows()
> function to return
[quoted text clipped - 28 lines]
> > e-zdocument, it throws off my window counting against words alphabetical
> > window sequencing. Ideas?
Perry - 07 Mar 2005 00:25 GMT
Pass the object variable as a parameter to the subroutine

Example:

Sub MySubRoutine(ByVal InvoiceDoc As Word.Document)
   'do your stuff here
End Sub

Calling the subroutine from another routine wud sound like:

Sub OtherRoutine()
Dim oDoc_Invoice As Word.Document
Set oDoc_Invoice = Documents.Add("c:\MyPath\Invoice.dot")
'<< do some stuff here to the document

'<< this is where you call a subroutine, note the parameter
MySubRoutine oDoc_Invoice

End Sub

Krgrds,
Perry

> Thanks for your thoughts Perry. I can see how this can help in one subroutine
> but after the documents are open, how do I tell other subroutines in my
[quoted text clipped - 32 lines]
> > > e-zdocument, it throws off my window counting against words alphabetical
> > > window sequencing. Ideas?
 
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.