I have created a userform in Word using VBA with several command buttons on
the form. One of the command buttons on the form inserts a custom footnote.
While the code works perfectly well, the command button on the form continues
to keep the focus, not the newly created footnote, where the user is supposed
to enter their text. Is there a routine I can call to set the focus to the
document window where the selection is so the user can automatically start
typing the footnote text immediately after clicking on the command button on
the user form?

Thanks for any help.

Lloyd

RE: switching focus by Lloyd

Lloyd
Tue Sep 05 15:17:02 CDT 2006

I should add a couple of other bits of information in case it's helpful:
1. The form is running in a modeless state
2. I'm trying not to have to close the form in order to return the focus
the active document window, since that means adding code to show the form
again once the user has completed their immediate task, and the form is
essentially a custom made toolbar which I want to keep open all the time
while the document is open.
3. The current situation requires the user to physically click in the
active document window after running any of the utilities on from the form
before they can actually continue working in the document. This is makes it
less intuitive to the user and slows the process down.
Thanks again for any suggestions on this.

Lloyd

"Lloyd" wrote:

> I have created a userform in Word using VBA with several command buttons on
> the form. One of the command buttons on the form inserts a custom footnote.
> While the code works perfectly well, the command button on the form continues
> to keep the focus, not the newly created footnote, where the user is supposed
> to enter their text. Is there a routine I can call to set the focus to the
> document window where the selection is so the user can automatically start
> typing the footnote text immediately after clicking on the command button on
> the user form?
>
> Thanks for any help.
>
> Lloyd

Re: switching focus by Doug

Doug
Tue Sep 05 22:53:22 CDT 2006

Another way to do it would be to have the button display an input box into
which the user enters the data for the footnote and when the click on OK in
the input box what they entered into the input box would be placed into a
footnote.

--
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

"Lloyd" <Lloyd@discussions.microsoft.com> wrote in message
news:E6257A3D-AEC0-4474-A7AA-1AC31F0F473A@microsoft.com...
>I should add a couple of other bits of information in case it's helpful:
> 1. The form is running in a modeless state
> 2. I'm trying not to have to close the form in order to return the focus
> the active document window, since that means adding code to show the form
> again once the user has completed their immediate task, and the form is
> essentially a custom made toolbar which I want to keep open all the time
> while the document is open.
> 3. The current situation requires the user to physically click in the
> active document window after running any of the utilities on from the form
> before they can actually continue working in the document. This is makes
> it
> less intuitive to the user and slows the process down.
> Thanks again for any suggestions on this.
>
> Lloyd
>
> "Lloyd" wrote:
>
>> I have created a userform in Word using VBA with several command buttons
>> on
>> the form. One of the command buttons on the form inserts a custom
>> footnote.
>> While the code works perfectly well, the command button on the form
>> continues
>> to keep the focus, not the newly created footnote, where the user is
>> supposed
>> to enter their text. Is there a routine I can call to set the focus to
>> the
>> document window where the selection is so the user can automatically
>> start
>> typing the footnote text immediately after clicking on the command button
>> on
>> the user form?
>>
>> Thanks for any help.
>>
>> Lloyd



Re: switching focus by Lloyd

Lloyd
Wed Sep 06 08:46:02 CDT 2006

Thanks for your suggestion Doug. Unfortunately this only delays the point at
which the user has to make that extra click to activate the document window,
as the form is there only to to provide tools for the user while they work
directly in the document.

What I'm trying to achieve is a seamless ongoing use of the commands on the
form while working in the document, without having to click back into the
document everytime you need use a command.

Thanks anyway. Your suggestion was greatly appreciated.

Lloyd

"Doug Robbins - Word MVP" wrote:

> Another way to do it would be to have the button display an input box into
> which the user enters the data for the footnote and when the click on OK in
> the input box what they entered into the input box would be placed into a
> footnote.
>
> --
> 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
>
> "Lloyd" <Lloyd@discussions.microsoft.com> wrote in message
> news:E6257A3D-AEC0-4474-A7AA-1AC31F0F473A@microsoft.com...
> >I should add a couple of other bits of information in case it's helpful:
> > 1. The form is running in a modeless state
> > 2. I'm trying not to have to close the form in order to return the focus
> > the active document window, since that means adding code to show the form
> > again once the user has completed their immediate task, and the form is
> > essentially a custom made toolbar which I want to keep open all the time
> > while the document is open.
> > 3. The current situation requires the user to physically click in the
> > active document window after running any of the utilities on from the form
> > before they can actually continue working in the document. This is makes
> > it
> > less intuitive to the user and slows the process down.
> > Thanks again for any suggestions on this.
> >
> > Lloyd
> >
> > "Lloyd" wrote:
> >
> >> I have created a userform in Word using VBA with several command buttons
> >> on
> >> the form. One of the command buttons on the form inserts a custom
> >> footnote.
> >> While the code works perfectly well, the command button on the form
> >> continues
> >> to keep the focus, not the newly created footnote, where the user is
> >> supposed
> >> to enter their text. Is there a routine I can call to set the focus to
> >> the
> >> document window where the selection is so the user can automatically
> >> start
> >> typing the footnote text immediately after clicking on the command button
> >> on
> >> the user form?
> >>
> >> Thanks for any help.
> >>
> >> Lloyd
>
>
>

Re: switching focus by Russ

Russ
Sun Sep 10 01:53:14 CDT 2006

Hi Lloyd,

Doesn't the .activate method return focus to the document?
The .goto method navigates footnotes and other document features.
So after using Doug's suggestion, you could have the document automatically
activated and gone to the footnote it inserted.

> Thanks for your suggestion Doug. Unfortunately this only delays the point at
> which the user has to make that extra click to activate the document window,
> as the form is there only to to provide tools for the user while they work
> directly in the document.
>
> What I'm trying to achieve is a seamless ongoing use of the commands on the
> form while working in the document, without having to click back into the
> document everytime you need use a command.
>
> Thanks anyway. Your suggestion was greatly appreciated.
>
> Lloyd
>
> "Doug Robbins - Word MVP" wrote:
>
>> Another way to do it would be to have the button display an input box into
>> which the user enters the data for the footnote and when the click on OK in
>> the input box what they entered into the input box would be placed into a
>> footnote.
>>
>> --
>> 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
>>
>> "Lloyd" <Lloyd@discussions.microsoft.com> wrote in message
>> news:E6257A3D-AEC0-4474-A7AA-1AC31F0F473A@microsoft.com...
>>> I should add a couple of other bits of information in case it's helpful:
>>> 1. The form is running in a modeless state
>>> 2. I'm trying not to have to close the form in order to return the focus
>>> the active document window, since that means adding code to show the form
>>> again once the user has completed their immediate task, and the form is
>>> essentially a custom made toolbar which I want to keep open all the time
>>> while the document is open.
>>> 3. The current situation requires the user to physically click in the
>>> active document window after running any of the utilities on from the form
>>> before they can actually continue working in the document. This is makes
>>> it
>>> less intuitive to the user and slows the process down.
>>> Thanks again for any suggestions on this.
>>>
>>> Lloyd
>>>
>>> "Lloyd" wrote:
>>>
>>>> I have created a userform in Word using VBA with several command buttons
>>>> on
>>>> the form. One of the command buttons on the form inserts a custom
>>>> footnote.
>>>> While the code works perfectly well, the command button on the form
>>>> continues
>>>> to keep the focus, not the newly created footnote, where the user is
>>>> supposed
>>>> to enter their text. Is there a routine I can call to set the focus to
>>>> the
>>>> document window where the selection is so the user can automatically
>>>> start
>>>> typing the footnote text immediately after clicking on the command button
>>>> on
>>>> the user form?
>>>>
>>>> Thanks for any help.
>>>>
>>>> Lloyd
>>
>>
>>

--
Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID


Re: switching focus by Lloyd

Lloyd
Mon Sep 11 11:53:02 CDT 2006

Russ,thanks for offering a thought on this. Actually, the .activate method
was one of the first things I tried. But I've not been successful with it.
I believe the .activate method isn't working because it seems that the form
is part of the same object that the activate method is being called from,
such as "ThisDocument.Activate". And ithe activate method doesn't seem to be
able to distinguish between different parts of the "ThisDocument" object. So
it appears the activate method is merely refreshing the focus on whatever
already has the focus in the active window, namely the form.

Perhaps an API call is necessary here. I'm playing around with some code
for that at present. If I come up with anything that works I'll be sure to
post it. Nevertheless, I do appreciate your input and any other thoughts you
might have on the subject.

Lloyd

"Russ" wrote:

> Hi Lloyd,
>
> Doesn't the .activate method return focus to the document?
> The .goto method navigates footnotes and other document features.
> So after using Doug's suggestion, you could have the document automatically
> activated and gone to the footnote it inserted.
>
> > Thanks for your suggestion Doug. Unfortunately this only delays the point at
> > which the user has to make that extra click to activate the document window,
> > as the form is there only to to provide tools for the user while they work
> > directly in the document.
> >
> > What I'm trying to achieve is a seamless ongoing use of the commands on the
> > form while working in the document, without having to click back into the
> > document everytime you need use a command.
> >
> > Thanks anyway. Your suggestion was greatly appreciated.
> >
> > Lloyd
> >
> > "Doug Robbins - Word MVP" wrote:
> >
> >> Another way to do it would be to have the button display an input box into
> >> which the user enters the data for the footnote and when the click on OK in
> >> the input box what they entered into the input box would be placed into a
> >> footnote.
> >>
> >> --
> >> 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
> >>
> >> "Lloyd" <Lloyd@discussions.microsoft.com> wrote in message
> >> news:E6257A3D-AEC0-4474-A7AA-1AC31F0F473A@microsoft.com...
> >>> I should add a couple of other bits of information in case it's helpful:
> >>> 1. The form is running in a modeless state
> >>> 2. I'm trying not to have to close the form in order to return the focus
> >>> the active document window, since that means adding code to show the form
> >>> again once the user has completed their immediate task, and the form is
> >>> essentially a custom made toolbar which I want to keep open all the time
> >>> while the document is open.
> >>> 3. The current situation requires the user to physically click in the
> >>> active document window after running any of the utilities on from the form
> >>> before they can actually continue working in the document. This is makes
> >>> it
> >>> less intuitive to the user and slows the process down.
> >>> Thanks again for any suggestions on this.
> >>>
> >>> Lloyd
> >>>
> >>> "Lloyd" wrote:
> >>>
> >>>> I have created a userform in Word using VBA with several command buttons
> >>>> on
> >>>> the form. One of the command buttons on the form inserts a custom
> >>>> footnote.
> >>>> While the code works perfectly well, the command button on the form
> >>>> continues
> >>>> to keep the focus, not the newly created footnote, where the user is
> >>>> supposed
> >>>> to enter their text. Is there a routine I can call to set the focus to
> >>>> the
> >>>> document window where the selection is so the user can automatically
> >>>> start
> >>>> typing the footnote text immediately after clicking on the command button
> >>>> on
> >>>> the user form?
> >>>>
> >>>> Thanks for any help.
> >>>>
> >>>> Lloyd
> >>
> >>
> >>
>
> --
> Russ
>
> drsmN0SPAMikleAThotmailD0Tcom.INVALID
>
>

Re: switching focus by Tony

Tony
Mon Sep 11 15:13:47 CDT 2006

You need to use Application.Activate, not ThisDocument.Activate.

--
Enjoy,
Tony

"Lloyd" <Lloyd@discussions.microsoft.com> wrote in message
news:D1163861-4E80-44DA-A5CF-E2C4DE344FE4@microsoft.com...
> Russ,thanks for offering a thought on this. Actually, the .activate
method
> was one of the first things I tried. But I've not been successful with
it.
> I believe the .activate method isn't working because it seems that the
form
> is part of the same object that the activate method is being called from,
> such as "ThisDocument.Activate". And ithe activate method doesn't seem to
be
> able to distinguish between different parts of the "ThisDocument" object.
So
> it appears the activate method is merely refreshing the focus on whatever
> already has the focus in the active window, namely the form.
>
> Perhaps an API call is necessary here. I'm playing around with some code
> for that at present. If I come up with anything that works I'll be sure
to
> post it. Nevertheless, I do appreciate your input and any other thoughts
you
> might have on the subject.
>
> Lloyd
>
> "Russ" wrote:
>
> > Hi Lloyd,
> >
> > Doesn't the .activate method return focus to the document?
> > The .goto method navigates footnotes and other document features.
> > So after using Doug's suggestion, you could have the document
automatically
> > activated and gone to the footnote it inserted.
> >
> > > Thanks for your suggestion Doug. Unfortunately this only delays the
point at
> > > which the user has to make that extra click to activate the document
window,
> > > as the form is there only to to provide tools for the user while they
work
> > > directly in the document.
> > >
> > > What I'm trying to achieve is a seamless ongoing use of the commands
on the
> > > form while working in the document, without having to click back into
the
> > > document everytime you need use a command.
> > >
> > > Thanks anyway. Your suggestion was greatly appreciated.
> > >
> > > Lloyd
> > >
> > > "Doug Robbins - Word MVP" wrote:
> > >
> > >> Another way to do it would be to have the button display an input box
into
> > >> which the user enters the data for the footnote and when the click on
OK in
> > >> the input box what they entered into the input box would be placed
into a
> > >> footnote.
> > >>
> > >> --
> > >> 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
> > >>
> > >> "Lloyd" <Lloyd@discussions.microsoft.com> wrote in message
> > >> news:E6257A3D-AEC0-4474-A7AA-1AC31F0F473A@microsoft.com...
> > >>> I should add a couple of other bits of information in case it's
helpful:
> > >>> 1. The form is running in a modeless state
> > >>> 2. I'm trying not to have to close the form in order to return the
focus
> > >>> the active document window, since that means adding code to show the
form
> > >>> again once the user has completed their immediate task, and the form
is
> > >>> essentially a custom made toolbar which I want to keep open all the
time
> > >>> while the document is open.
> > >>> 3. The current situation requires the user to physically click in
the
> > >>> active document window after running any of the utilities on from
the form
> > >>> before they can actually continue working in the document. This is
makes
> > >>> it
> > >>> less intuitive to the user and slows the process down.
> > >>> Thanks again for any suggestions on this.
> > >>>
> > >>> Lloyd
> > >>>
> > >>> "Lloyd" wrote:
> > >>>
> > >>>> I have created a userform in Word using VBA with several command
buttons
> > >>>> on
> > >>>> the form. One of the command buttons on the form inserts a custom
> > >>>> footnote.
> > >>>> While the code works perfectly well, the command button on the form
> > >>>> continues
> > >>>> to keep the focus, not the newly created footnote, where the user
is
> > >>>> supposed
> > >>>> to enter their text. Is there a routine I can call to set the
focus to
> > >>>> the
> > >>>> document window where the selection is so the user can
automatically
> > >>>> start
> > >>>> typing the footnote text immediately after clicking on the command
button
> > >>>> on
> > >>>> the user form?
> > >>>>
> > >>>> Thanks for any help.
> > >>>>
> > >>>> Lloyd
> > >>
> > >>
> > >>
> >
> > --
> > Russ
> >
> > drsmN0SPAMikleAThotmailD0Tcom.INVALID
> >
> >



Re: switching focus by Lloyd

Lloyd
Mon Sep 11 17:46:01 CDT 2006

Thanks a million, Tony. That worked perfectly. I could kick myself for not
trying that. The application object is not as high up on the chain as I
thought it was. I assumed the application object was Do you by any chance
know where I can get a copy of the full VBA object model tree? It would be
hugely helpful.

Thanks again for zeroing in on the solution.

Lloyd

"Tony Jollans" wrote:

> You need to use Application.Activate, not ThisDocument.Activate.
>
> --
> Enjoy,
> Tony
>
> "Lloyd" <Lloyd@discussions.microsoft.com> wrote in message
> news:D1163861-4E80-44DA-A5CF-E2C4DE344FE4@microsoft.com...
> > Russ,thanks for offering a thought on this. Actually, the .activate
> method
> > was one of the first things I tried. But I've not been successful with
> it.
> > I believe the .activate method isn't working because it seems that the
> form
> > is part of the same object that the activate method is being called from,
> > such as "ThisDocument.Activate". And ithe activate method doesn't seem to
> be
> > able to distinguish between different parts of the "ThisDocument" object.
> So
> > it appears the activate method is merely refreshing the focus on whatever
> > already has the focus in the active window, namely the form.
> >
> > Perhaps an API call is necessary here. I'm playing around with some code
> > for that at present. If I come up with anything that works I'll be sure
> to
> > post it. Nevertheless, I do appreciate your input and any other thoughts
> you
> > might have on the subject.
> >
> > Lloyd
> >
> > "Russ" wrote:
> >
> > > Hi Lloyd,
> > >
> > > Doesn't the .activate method return focus to the document?
> > > The .goto method navigates footnotes and other document features.
> > > So after using Doug's suggestion, you could have the document
> automatically
> > > activated and gone to the footnote it inserted.
> > >
> > > > Thanks for your suggestion Doug. Unfortunately this only delays the
> point at
> > > > which the user has to make that extra click to activate the document
> window,
> > > > as the form is there only to to provide tools for the user while they
> work
> > > > directly in the document.
> > > >
> > > > What I'm trying to achieve is a seamless ongoing use of the commands
> on the
> > > > form while working in the document, without having to click back into
> the
> > > > document everytime you need use a command.
> > > >
> > > > Thanks anyway. Your suggestion was greatly appreciated.
> > > >
> > > > Lloyd
> > > >
> > > > "Doug Robbins - Word MVP" wrote:
> > > >
> > > >> Another way to do it would be to have the button display an input box
> into
> > > >> which the user enters the data for the footnote and when the click on
> OK in
> > > >> the input box what they entered into the input box would be placed
> into a
> > > >> footnote.
> > > >>
> > > >> --
> > > >> 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
> > > >>
> > > >> "Lloyd" <Lloyd@discussions.microsoft.com> wrote in message
> > > >> news:E6257A3D-AEC0-4474-A7AA-1AC31F0F473A@microsoft.com...
> > > >>> I should add a couple of other bits of information in case it's
> helpful:
> > > >>> 1. The form is running in a modeless state
> > > >>> 2. I'm trying not to have to close the form in order to return the
> focus
> > > >>> the active document window, since that means adding code to show the
> form
> > > >>> again once the user has completed their immediate task, and the form
> is
> > > >>> essentially a custom made toolbar which I want to keep open all the
> time
> > > >>> while the document is open.
> > > >>> 3. The current situation requires the user to physically click in
> the
> > > >>> active document window after running any of the utilities on from
> the form
> > > >>> before they can actually continue working in the document. This is
> makes
> > > >>> it
> > > >>> less intuitive to the user and slows the process down.
> > > >>> Thanks again for any suggestions on this.
> > > >>>
> > > >>> Lloyd
> > > >>>
> > > >>> "Lloyd" wrote:
> > > >>>
> > > >>>> I have created a userform in Word using VBA with several command
> buttons
> > > >>>> on
> > > >>>> the form. One of the command buttons on the form inserts a custom
> > > >>>> footnote.
> > > >>>> While the code works perfectly well, the command button on the form
> > > >>>> continues
> > > >>>> to keep the focus, not the newly created footnote, where the user
> is
> > > >>>> supposed
> > > >>>> to enter their text. Is there a routine I can call to set the
> focus to
> > > >>>> the
> > > >>>> document window where the selection is so the user can
> automatically
> > > >>>> start
> > > >>>> typing the footnote text immediately after clicking on the command
> button
> > > >>>> on
> > > >>>> the user form?
> > > >>>>
> > > >>>> Thanks for any help.
> > > >>>>
> > > >>>> Lloyd
> > > >>
> > > >>
> > > >>
> > >
> > > --
> > > Russ
> > >
> > > drsmN0SPAMikleAThotmailD0Tcom.INVALID
> > >
> > >
>
>
>

Re: switching focus by Tony

Tony
Tue Sep 12 01:21:05 CDT 2006

I think one needs to be very careful with terminology here to avoid
confusion (as best one can). The Application object is top of the tree, or
perhaps top of *a* tree and the trick to understanding this is to recognise
that a non-modal form is essentially separate from the application as far as
Windows is concerned.

The object model should be in Help but wouldn't really have helped with this
as it only shows Word objects; your own objects are not part of the same
tree.

--
Enjoy,
Tony

"Lloyd" <Lloyd@discussions.microsoft.com> wrote in message
news:87ACCF24-DB40-4D03-A4F7-F05070AA28C1@microsoft.com...
> Thanks a million, Tony. That worked perfectly. I could kick myself for
not
> trying that. The application object is not as high up on the chain as I
> thought it was. I assumed the application object was Do you by any chance
> know where I can get a copy of the full VBA object model tree? It would
be
> hugely helpful.
>
> Thanks again for zeroing in on the solution.
>
> Lloyd
>
> "Tony Jollans" wrote:
>
> > You need to use Application.Activate, not ThisDocument.Activate.
> >
> > --
> > Enjoy,
> > Tony
> >
> > "Lloyd" <Lloyd@discussions.microsoft.com> wrote in message
> > news:D1163861-4E80-44DA-A5CF-E2C4DE344FE4@microsoft.com...
> > > Russ,thanks for offering a thought on this. Actually, the .activate
> > method
> > > was one of the first things I tried. But I've not been successful
with
> > it.
> > > I believe the .activate method isn't working because it seems that the
> > form
> > > is part of the same object that the activate method is being called
from,
> > > such as "ThisDocument.Activate". And ithe activate method doesn't
seem to
> > be
> > > able to distinguish between different parts of the "ThisDocument"
object.
> > So
> > > it appears the activate method is merely refreshing the focus on
whatever
> > > already has the focus in the active window, namely the form.
> > >
> > > Perhaps an API call is necessary here. I'm playing around with some
code
> > > for that at present. If I come up with anything that works I'll be
sure
> > to
> > > post it. Nevertheless, I do appreciate your input and any other
thoughts
> > you
> > > might have on the subject.
> > >
> > > Lloyd
> > >
> > > "Russ" wrote:
> > >
> > > > Hi Lloyd,
> > > >
> > > > Doesn't the .activate method return focus to the document?
> > > > The .goto method navigates footnotes and other document features.
> > > > So after using Doug's suggestion, you could have the document
> > automatically
> > > > activated and gone to the footnote it inserted.
> > > >
> > > > > Thanks for your suggestion Doug. Unfortunately this only delays
the
> > point at
> > > > > which the user has to make that extra click to activate the
document
> > window,
> > > > > as the form is there only to to provide tools for the user while
they
> > work
> > > > > directly in the document.
> > > > >
> > > > > What I'm trying to achieve is a seamless ongoing use of the
commands
> > on the
> > > > > form while working in the document, without having to click back
into
> > the
> > > > > document everytime you need use a command.
> > > > >
> > > > > Thanks anyway. Your suggestion was greatly appreciated.
> > > > >
> > > > > Lloyd
> > > > >
> > > > > "Doug Robbins - Word MVP" wrote:
> > > > >
> > > > >> Another way to do it would be to have the button display an input
box
> > into
> > > > >> which the user enters the data for the footnote and when the
click on
> > OK in
> > > > >> the input box what they entered into the input box would be
placed
> > into a
> > > > >> footnote.
> > > > >>
> > > > >> --
> > > > >> 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
> > > > >>
> > > > >> "Lloyd" <Lloyd@discussions.microsoft.com> wrote in message
> > > > >> news:E6257A3D-AEC0-4474-A7AA-1AC31F0F473A@microsoft.com...
> > > > >>> I should add a couple of other bits of information in case it's
> > helpful:
> > > > >>> 1. The form is running in a modeless state
> > > > >>> 2. I'm trying not to have to close the form in order to return
the
> > focus
> > > > >>> the active document window, since that means adding code to show
the
> > form
> > > > >>> again once the user has completed their immediate task, and the
form
> > is
> > > > >>> essentially a custom made toolbar which I want to keep open all
the
> > time
> > > > >>> while the document is open.
> > > > >>> 3. The current situation requires the user to physically click
in
> > the
> > > > >>> active document window after running any of the utilities on
from
> > the form
> > > > >>> before they can actually continue working in the document. This
is
> > makes
> > > > >>> it
> > > > >>> less intuitive to the user and slows the process down.
> > > > >>> Thanks again for any suggestions on this.
> > > > >>>
> > > > >>> Lloyd
> > > > >>>
> > > > >>> "Lloyd" wrote:
> > > > >>>
> > > > >>>> I have created a userform in Word using VBA with several
command
> > buttons
> > > > >>>> on
> > > > >>>> the form. One of the command buttons on the form inserts a
custom
> > > > >>>> footnote.
> > > > >>>> While the code works perfectly well, the command button on the
form
> > > > >>>> continues
> > > > >>>> to keep the focus, not the newly created footnote, where the
user
> > is
> > > > >>>> supposed
> > > > >>>> to enter their text. Is there a routine I can call to set the
> > focus to
> > > > >>>> the
> > > > >>>> document window where the selection is so the user can
> > automatically
> > > > >>>> start
> > > > >>>> typing the footnote text immediately after clicking on the
command
> > button
> > > > >>>> on
> > > > >>>> the user form?
> > > > >>>>
> > > > >>>> Thanks for any help.
> > > > >>>>
> > > > >>>> Lloyd
> > > > >>
> > > > >>
> > > > >>
> > > >
> > > > --
> > > > Russ
> > > >
> > > > drsmN0SPAMikleAThotmailD0Tcom.INVALID
> > > >
> > > >
> >
> >
> >



Re: switching focus by Russ

Russ
Thu Sep 14 03:37:41 CDT 2006

Lloyd,

> You need to use Application.Activate, not ThisDocument.Activate.
Especially not ThisDocument, since ThisDocument may refer to a underlying
template containing vba modules that created your currently open working,
non-template document. So if your template wasn't currently open in Word for
editing, then ThisDocument.activate would not bring the template or any
other document to the forefront.

Below is quote from VBA Help:

"Activate Method Example
This example activates the document named "Sales.doc."
Documents("Sales.doc").Activate
This example activates the next window in the Windows collection.
ActiveWindow.Next.Activate
This example splits the active window and then activates the first pane.
With ActiveWindow
.SplitVertical = 50
.Panes(1).Activate
End With"

I thought you would read that and choose the first example and activate your
working document by name, assuming that you had captured the name earlier
with ActiveDocument.Name when it did have focus.

>
> --
> Enjoy,
> Tony
>
> "Lloyd" <Lloyd@discussions.microsoft.com> wrote in message
> news:D1163861-4E80-44DA-A5CF-E2C4DE344FE4@microsoft.com...
>> Russ,thanks for offering a thought on this. Actually, the .activate
> method
>> was one of the first things I tried. But I've not been successful with
> it.
>> I believe the .activate method isn't working because it seems that the
> form
>> is part of the same object that the activate method is being called from,
>> such as "ThisDocument.Activate". And ithe activate method doesn't seem to
> be
>> able to distinguish between different parts of the "ThisDocument" object.
> So
>> it appears the activate method is merely refreshing the focus on whatever
>> already has the focus in the active window, namely the form.
>>
>> Perhaps an API call is necessary here. I'm playing around with some code
>> for that at present. If I come up with anything that works I'll be sure
> to
>> post it. Nevertheless, I do appreciate your input and any other thoughts
> you
>> might have on the subject.
>>
>> Lloyd
>>
>> "Russ" wrote:
>>
>>> Hi Lloyd,
>>>
>>> Doesn't the .activate method return focus to the document?
>>> The .goto method navigates footnotes and other document features.
>>> So after using Doug's suggestion, you could have the document
> automatically
>>> activated and gone to the footnote it inserted.
>>>
>>>> Thanks for your suggestion Doug. Unfortunately this only delays the
> point at
>>>> which the user has to make that extra click to activate the document
> window,
>>>> as the form is there only to to provide tools for the user while they
> work
>>>> directly in the document.
>>>>
>>>> What I'm trying to achieve is a seamless ongoing use of the commands
> on the
>>>> form while working in the document, without having to click back into
> the
>>>> document everytime you need use a command.
>>>>
>>>> Thanks anyway. Your suggestion was greatly appreciated.
>>>>
>>>> Lloyd
>>>>
>>>> "Doug Robbins - Word MVP" wrote:
>>>>
>>>>> Another way to do it would be to have the button display an input box
> into
>>>>> which the user enters the data for the footnote and when the click on
> OK in
>>>>> the input box what they entered into the input box would be placed
> into a
>>>>> footnote.
>>>>>
>>>>> --
>>>>> 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
>>>>>
>>>>> "Lloyd" <Lloyd@discussions.microsoft.com> wrote in message
>>>>> news:E6257A3D-AEC0-4474-A7AA-1AC31F0F473A@microsoft.com...
>>>>>> I should add a couple of other bits of information in case it's
> helpful:
>>>>>> 1. The form is running in a modeless state
>>>>>> 2. I'm trying not to have to close the form in order to return the
> focus
>>>>>> the active document window, since that means adding code to show the
> form
>>>>>> again once the user has completed their immediate task, and the form
> is
>>>>>> essentially a custom made toolbar which I want to keep open all the
> time
>>>>>> while the document is open.
>>>>>> 3. The current situation requires the user to physically click in
> the
>>>>>> active document window after running any of the utilities on from
> the form
>>>>>> before they can actually continue working in the document. This is
> makes
>>>>>> it
>>>>>> less intuitive to the user and slows the process down.
>>>>>> Thanks again for any suggestions on this.
>>>>>>
>>>>>> Lloyd
>>>>>>
>>>>>> "Lloyd" wrote:
>>>>>>
>>>>>>> I have created a userform in Word using VBA with several command
> buttons
>>>>>>> on
>>>>>>> the form. One of the command buttons on the form inserts a custom
>>>>>>> footnote.
>>>>>>> While the code works perfectly well, the command button on the form
>>>>>>> continues
>>>>>>> to keep the focus, not the newly created footnote, where the user
> is
>>>>>>> supposed
>>>>>>> to enter their text. Is there a routine I can call to set the
> focus to
>>>>>>> the
>>>>>>> document window where the selection is so the user can
> automatically
>>>>>>> start
>>>>>>> typing the footnote text immediately after clicking on the command
> button
>>>>>>> on
>>>>>>> the user form?
>>>>>>>
>>>>>>> Thanks for any help.
>>>>>>>
>>>>>>> Lloyd
>>>>>
>>>>>
>>>>>
>>>
>>> --
>>> Russ
>>>
>>> drsmN0SPAMikleAThotmailD0Tcom.INVALID
>>>
>>>
>
>

--
Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID