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?