J
Jean-Guy Marcil
Hi all!
I have a template that contains a complicated userform that lets the user
create a document according to the type of information they want and
according to corporate policies. Also, the template has customized toolbars
that offer assistance for later editing. The toolbar content is drastically
different based on the type of document created.
So, I built 4 toolbars by code, finished them by hand and added a
DocumentChange event to display the appropriate toolbar depending on the
type of document (which contains a DocVariable to tell the Change event
which toolbar to display).
So far, so good, everything works as I wanted.
I have, however, just discovered a small annoyance and after spending a few
hours on this I need help!
Let's say I create a document and save it (calling it Test1.doc)
I close Word.
I open Test1.doc
I double click on the template name in Windows Explorer to create a new
document based on the same template that Test1.doc is based on.
The procedure runs fine, I select my info and type of document through the
userform.
I click OK on the said userform.
The code runs and does its job.
When it has finished, the Windows taskbar highlights Document1 which has
just been created, but the screen displays Test1.doc.
This only happens in this case. If I create a document based on the template
and not save (leave it on the screen unsaved) and create a second document I
never see this behaviour.
If I keep creating documents based on the same template when Test1.doc is
first opened, then the document preceding the cone being created ends up
being displayed (i.e., when creating Document2, Document 1 ends up on the
screen while Document2 is highlighted on the taskbar, etc.)
I have tried adding ActiveWindow.SetFocus and/or ActivePane.Activate using
either ActiveDocument or Documents("DocumentName") to no avail. The funny
thing is that sometimes it does not do that.
Is this a coding, a Word or a display problem?
TIA
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
I have a template that contains a complicated userform that lets the user
create a document according to the type of information they want and
according to corporate policies. Also, the template has customized toolbars
that offer assistance for later editing. The toolbar content is drastically
different based on the type of document created.
So, I built 4 toolbars by code, finished them by hand and added a
DocumentChange event to display the appropriate toolbar depending on the
type of document (which contains a DocVariable to tell the Change event
which toolbar to display).
So far, so good, everything works as I wanted.
I have, however, just discovered a small annoyance and after spending a few
hours on this I need help!
Let's say I create a document and save it (calling it Test1.doc)
I close Word.
I open Test1.doc
I double click on the template name in Windows Explorer to create a new
document based on the same template that Test1.doc is based on.
The procedure runs fine, I select my info and type of document through the
userform.
I click OK on the said userform.
The code runs and does its job.
When it has finished, the Windows taskbar highlights Document1 which has
just been created, but the screen displays Test1.doc.
This only happens in this case. If I create a document based on the template
and not save (leave it on the screen unsaved) and create a second document I
never see this behaviour.
If I keep creating documents based on the same template when Test1.doc is
first opened, then the document preceding the cone being created ends up
being displayed (i.e., when creating Document2, Document 1 ends up on the
screen while Document2 is highlighted on the taskbar, etc.)
I have tried adding ActiveWindow.SetFocus and/or ActivePane.Activate using
either ActiveDocument or Documents("DocumentName") to no avail. The funny
thing is that sometimes it does not do that.
Is this a coding, a Word or a display problem?
TIA
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org