VBA: How to remove focus

S

Sandi

Hello,

I'm using PPT2003 on WinXP and I've created a form that captures user input
and appends to a file. I'm by no means a scripting guru but I've managed to
create this form containing checkboxes, text boxes, a submit button I created
from the Control Toolbox along with several Next/Previous navigation buttons
inserted from the PPT SlideShow interactive menu. The show works fine with
the exception of the control focus. When users click to check a box, the
focus remains on the checkbox. This creates an extra click for the user when
they want to click the Next button (or Submit button) since they first have
to click the button to activate it then click the button again to execute it.

Does anyone have a quick and dirty code solution for this?

Thanks,
Sandi
 
B

Brian Reilly, MVP

Sandi,
I probably have a simple and quick solution, not dirty, for this but I
still don't understand your question well enough to post a simple
piece of code to do this without understanding more detail about your
steps.

Others may get your question more precisely and post code, shouldn't
be much more than a line or two of code.

Brian Reilly, MVP
 
S

Sandi

Thanks for responding, Brian.

I'll try to clarify my situation...

Using the Control Toolbox, I've created a ppt comprised of multiple slides
all containing checkboxes, textboxes, and buttons. Also, each slide has a
Next button to advance to the next slide. Additionally, the last slide has a
Submit button to accept the input from each of the previous slides. I also
added script that captures the input then appends it to a file on my network
- with success.

However, when I run the slide show, and tick a checkbox a dotted line
surrounds the entire control, which I believe is called a focus. When I
attempt to advance to the next slide by clicking the Next button, nothing
happens. But when I click the Next button a second time, the slide advances
(I have to click the Next button 2x).

What I think is happening is with the first click, I am deactivating the
focus on the checkbox and with the second click I am then executing the click
command for the button.

I'm hoping there is a way to remove the focus all together for the above
reason, not to mention, it makes poor readability on this particular
slideshow presentation.

Thanks,
Sandi.
 
J

John Wilson

Hi Sandi

I just made a quick form and for me, yes I get the dotted line round the
text (I usually leave the text blank and use a label) but it doesn't stop me
using the command button on first click. Maybe there's something in your code
doing this??
--
Amazing PPT Hints, Tips and Tutorials

http://www.PPTAlchemy.co.uk
http://www.technologytrish.co.uk
email john AT technologytrish.co.uk
 
S

Sandi

Lucky you, John. :blush:)

Not sure why it doesn't happen the same for me. I'm using a *very simple*
script of about 4 or 5 lines.

Open file to append
Write contents to file
Pop-up message box as confirmation
Clear fields
Close file

Nothing that relates to setfocus, activateshape, tabindex, etc. But I do
wonder how I could use any of those functions to remove or advance the focus.
 
S

Sandi

That is correct. I've inserted the controls directly into the slide.

Chirag, thank you for making that distinction.
 
S

Steve Rindsberg

I'm seeing the same thing, Sandi. My theory for the moment:

The controls are OLE objects, meaning that they don't really belong to PPT but are
"owned" by another program (something like content pasted from Excel). While
they're a special case, in that they're activated by single click rather than
having to doubleclick, they do take focus away from the current slide (and anything
else on it).

I think you'll notice that once you've clicked on one of these controls, you don't
necessarily have to click twice on the Next button ... you can instead click
anywhere on the slide itself to return focus to the slide, then clicking the next
button will work.

Now all that blather assumes you're using an Action Button or some other shape with
an action setting as your Next Slide button.

Instead of that, add a command button from the control toolbox and add something
like this to its Click event:

SlideShowWindows(1).View.GotoSlide (2)

Change that last 2 to whatever slide number you want to jump to ... this is crude,
but it's just a test. If it does what you want, we can fix you up with some more
elegant code.
 
A

Austin Myers

Sandi,

How about a simple solution? Assuming you have a checkbox1 control on the
slide:

Private Sub CheckBox1_Change()
CheckBox1.Visible = False
CheckBox1.Visible = True
End Sub

What does this do? If the control's visible property is set to false, it
can not have the focus. By turning this property to false it loses focus
(focus is returned to the slide). We then set it to True so the user can
still see it. This will happen so fast the human eye can't detect it. I
picked the "Change" as that is really the only time you want the code to
fire but it could be done with "OnClick" etc.


Austin Myers
MS PowerPoint MVP Team

Provider of PFCPro, PFCMedia and PFCExpress
www.playsforcertain.com
 
A

Austin Myers

By the way folks, this little trick can be used with almost any activex
control including the Windows Media Player. Just figure out what event you
want to use to fire the code.
 
S

Steve Rindsberg

Sandi,

How about a simple solution? Assuming you have a checkbox1 control on the
slide:

Private Sub CheckBox1_Change()
CheckBox1.Visible = False
CheckBox1.Visible = True
End Sub

Ooo, that's brilliant, Austin.
 
S

Shyam Pillai

Sandi,

You can also use the following snippet to remove the focus:

With SlideShowWindows(1).View
.GotoSlide .CurrentShowPosition, False
End With


--
Regards,
Shyam Pillai

Animation Carbon: Copy/Paste/Share animation libraries.
www.animationcarbon.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top