Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 244
Default Trouble w/ ActiveX Controls (no userform) Excel 2002.

Hi all,

I have a spreadsheet that is constantly populating combo
boxes (ActiveX) whenever a checkbox is clicked or some
other event occurs. The combo boxes are populated in
modules using the .AddItem method upon the opening of the
workbook, and upon a checkbox = true click event. The
issue arises that whenever I close the workbook the combo
box unpopulates and forgets the user selection that was
made.

When the workbook is saved I want it to remember the value
that the user last selected in each combo box and to avoid
the run time error 1004. Often times the combo box text
property is blank and doesn't contain anything because it
doesn't apply to the project.

Please help me determine the best way to accomplish this.
I have 30 combo boxes I need to do this for. Thanks in
advance!

Example of what I have done below.
This errors out the varBatesNumberingChange line. I can't
figure out how to fix it.

Public Sub cboBatesNumbering_Change()

Dim varBatesNumberingChange As Variant

varBatesNumberingChange = Sheets
("Input").cboBatesNumbering.Text

If Not IsNumeric(varBatesNumberingChange) = True And
varBatesNumberingChange < "" Then
Range("Input_cboBatesNumbering_choice").Value =
Sheets("Input").cboBatesNumbering.Text
Application.ScreenUpdating = True
Else
Range("Input_cboBatesNumbering_choice").Value = ""
Application.ScreenUpdating = True
End If
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 244
Default Trouble w/ ActiveX Controls (no userform) Excel 2002.

Patrick thanks for your reply.

In the workbook I have range names setup that I feed the
combo box values to. The main issue I am having is a (Run-
Time error '1004': Method 'Sheets' of object'_Global)
Error. This occurs in the cboBatesNumbering_Change
procedure below. If you could help me to correct the
syntax or structure of the code so it doesn't error out at
run time I would be forever indebted to you.
Unfortunately my project time on this is overdue. Thanks.

-----Original Message-----
the only way to do this would be to save the values

somewhere - the registry
perhaps? - each time a slection is made. when re-loading

the sheet the
activeX controls could be reset through the auto_open

procedure or the
workbook open event.

When you close a workbook, the application cleans up

memory by destroying
instances of the controls...hence they lose their data.

--
Patrick Molloy
Microsoft Excel MVP
----------------------------------
"Chris" wrote in

message
...
Hi all,

I have a spreadsheet that is constantly populating combo
boxes (ActiveX) whenever a checkbox is clicked or some
other event occurs. The combo boxes are populated in
modules using the .AddItem method upon the opening of

the
workbook, and upon a checkbox = true click event. The
issue arises that whenever I close the workbook the

combo
box unpopulates and forgets the user selection that was
made.

When the workbook is saved I want it to remember the

value
that the user last selected in each combo box and to

avoid
the run time error 1004. Often times the combo box text
property is blank and doesn't contain anything because

it
doesn't apply to the project.

Please help me determine the best way to accomplish

this.
I have 30 combo boxes I need to do this for. Thanks in
advance!

Example of what I have done below.
This errors out the varBatesNumberingChange line. I

can't
figure out how to fix it.

Public Sub cboBatesNumbering_Change()

Dim varBatesNumberingChange As Variant

varBatesNumberingChange = Sheets
("Input").cboBatesNumbering.Text

If Not IsNumeric(varBatesNumberingChange) = True And
varBatesNumberingChange < "" Then
Range("Input_cboBatesNumbering_choice").Value =
Sheets("Input").cboBatesNumbering.Text
Application.ScreenUpdating = True
Else
Range("Input_cboBatesNumbering_choice").Value

= ""
Application.ScreenUpdating = True
End If
End Sub



.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Trouble w/ ActiveX Controls (no userform) Excel 2002.

Chris,

The range objects you use are not "qualified"
e.g. are not pointed to a specific worksheet object.
It may be an Activesheet object, but in your case it's probably
a worksheet in the workbook from which you run the code.

ThisWorkbook.Worksheets("controls").Range("mynamed range")
would work best

Also remember that when you use ControlSource (which accepts cell's
address strings) to ALWAYS use the EXTERNAL address for a range.
(which is a fully qualifid address of workbook/sheet/range)

MyComboBOx1.ControlSource= myRng.address(external:=true)

This way you're sure you KNOW where it points, regardless of which book
or sheet is active when the form is loaded.


keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"Chris" wrote:

Patrick thanks for your reply.

In the workbook I have range names setup that I feed the
combo box values to. The main issue I am having is a (Run-
Time error '1004': Method 'Sheets' of object'_Global)
Error. This occurs in the cboBatesNumbering_Change
procedure below. If you could help me to correct the
syntax or structure of the code so it doesn't error out at
run time I would be forever indebted to you.
Unfortunately my project time on this is overdue. Thanks.

-----Original Message-----

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Activex controls in Excel 2003 Tom Stewart Excel Worksheet Functions 2 April 9th 07 04:46 PM
ActiveX Controls vs Form Controls Alex Excel Discussion (Misc queries) 1 January 11th 06 08:46 AM
Help with Excel ActiveX listbox controls programmer123 Excel Discussion (Misc queries) 0 July 7th 05 10:30 PM
Saving Excel with ActiveX controls Roopa New Users to Excel 0 February 9th 05 06:35 PM
ActiveX Controls on Excel sheets George Cooper Excel Programming 0 July 16th 03 07:54 AM


All times are GMT +1. The time now is 09:17 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"