There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Software Development
Tag Cloud
audio blue screen boot bsod computer cpu crash dell desktop driver drivers error excel external hard drive firefox freezes freezing hard drive hardware hijackthis internet internet explorer itunes laptop mac malware motherboard mouse network networking outlook 2007 power printer problem ram router screen slow sound trojan usb virus vista vista 32-bit windows windows vista windows xp winxp wireless wmp
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
Visual Basic in Excel - How do I change the 'focus'?


Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
Pond's Avatar
Junior Member with 2 posts.
 
Join Date: Aug 2003
Location: Canberra, Australia
08-Aug-2003, 01:18 AM #1
Visual Basic in Excel - How do I change the 'focus'?
Hi. I'm learning Visual Basic (in 21 days!) from a nice, fat, hardcover book. To make my life difficult, I'm using the Visual Basic functionality within Excel, rather than working with Visual Basic by itself. (A few reasons - we don't have Visual Basic at work, but we do have Excel. I also want to use Visual Basic to put together more advanced applications with Excel.)

So, the first few sample programs worked just fine. Now I've hit a snag.

The sample program I'm working on has three radio buttons and three images. You select which one of the images you want to move around by clicking the appropriate radio button. You then click anywhere on the form and the image then moves to there.

OK. The first problem I had was with the MouseDown (mouse click) event. It isn't clear to me how to tie a MouseDown event to an Excel sheet.

So I looked for a workaround. I added an image 'object' behind the radio buttons and the images, and sent it to the back. It's basically working as a background. I could then associate a MouseDown event with this background image.

The program now works. I click somewhere on the background image, and the selected image moves there.

The problem now is that the background image 'receives' the focus when you click on it, bringing it to the foreground, obscuring everything else. Once the mouse pointer is moved off the background image, the image again reverts to the background, letting you see the three radio buttons and the three images.

My question is - how do I stop the background image jumping into the foreground when I click on it? Or how do I send it back into the background immediately after I've clicked on it? Or is there maybe some other object I should be using to link to the MouseDown event? Or is there some way I could shift the focus to another object on the sheet which would take the focus away from the background image?
SabreWolf3's Avatar
Senior Member with 227 posts.
 
Join Date: Nov 2000
Location: Washington, DC
08-Aug-2003, 07:12 PM #2
Hi Pond,

I threw an example workbook together rather quickly, that will show you how to accomplish what you want in two ways. The first is a UserForm, and the second is in a sheet.

Move_Images.xls

See if that does what you expect, and then you can let me know if you have any further questions. I'll be gone for the weekend, but I'll return on Monday!

Regards,
Richard
__________________
If I have helped you, please donate to help keep the site FREE
Pond's Avatar
Junior Member with 2 posts.
 
Join Date: Aug 2003
Location: Canberra, Australia
12-Aug-2003, 08:36 PM #3
Thanks heaps, Richard. That'll make getting through the rest of the book a lot less trial and error.

You threw it together rather quickly? Man oh man. It looks way better than my first attempt, and even better than the example in the book...
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 08:27 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.