Question : Get the name of an active control

I have several text box controls in a worksheet. When a user selects a text box, I want to have the background of the text box change from white to light blue (and reverse on LostFocus). I can do this on the GotFocus event for the control but I have to use a direct reference to the control name (each time). I have 39 text boxes so I would like to be able to determine the name of the text box that has been selected (i.e., the text box that has the focus) and then set the property using that information. Thanks for any help.

1:
2:
3:
4:
5:
6:
7:
8:
Private Sub txtRecDevGen_GotFocus()
txtRecDevGen.BackColor = &HFFFFC0
End Sub

Private Sub txtRecDevGen_LostFocus()
txtRecDevGen.BackColor = &HFFFFFF
End Sub

Answer : Get the name of an active control

I'd do it more like this:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
#! /usr/bin/perl

use strict;
use warnings;
use File::Copy;
use File::Path;
use File::Basename;

my $web_dir = 'directory';
if (! -d 'directory.slb.com') {
   mkdir("$web_dir", 0777);
}

# file list to be checked out from CVS
my @CVSfiles = qw(
 development/web-files/help/file.xx
 development/web-files/help/file2.xx
 development/web-files/help/images/file.xx
 development/web-files/help/images/file2.xx
 development/web-files/help/change-process/file.xx
 development/web-files/help/change-process/file2.xx
 development/web-files/help/corporate-identity/file.xx
 development/web-files/help/corporate-identity/file2.xx
 development/web-files/help/example-clients/file.xx
 development/web-files/help/example-clients/file2.xx
);

foreach my $file ( @CVSfiles ) {
    my $dir = dirname($file);
    mkpath($dir) if ! -d $dir;
}
Random Solutions  
 
programming4us programming4us