LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Reference to ActiveX control on worksheet requires full worksheet name

I have a combobox called ReportMonth on a worksheet (i.e. not on a form)
called Summary. I want to include the current ReportMonth value (which can
change from one month to the next) in the CenterHeader along with some other
text, ready for printing, so I put the necessary code in the
Workbook_BeforePrint event module. This works fine, except that I can't set
a reference to the worksheet and use this when I refer to the combobox, I
have to use the full worksheet name i.e.:

Dim wks As Worksheet
Set wks = Worksheets("Summary")
....
[code to set CenterHeader]... wks.ReportMonth.Value ...
....

produces an Object Required error. I have to "spell it out" fully and do
this instead:

....
[code to set CenterHeader]... Worksheets("Summary").ReportMonth.Value ...
....

which works fine.

This might seem petty, but it seems to go against all the advice on setting
references to objects as good coding practice.

Why doesn't the neater code work?

Ian


 
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
How to create control button on worksheet: Forms v. ActiveX feature? [email protected] Excel Discussion (Misc queries) 2 February 16th 08 06:32 AM
how do you use the ActiveX Calendar control in an Excel Worksheet. EricF Excel Worksheet Functions 0 November 10th 04 09:39 PM
how to reference worksheet as control source with space in name Peter Bailey[_2_] Excel Programming 3 October 31st 04 12:33 PM
UDF showing full Path of Worksheet or Worksheet Name? PDX Excel Programming 1 April 13th 04 10:36 PM
Error 50290: Error writing to Worksheet while using an ActiveX Control emblair3 Excel Programming 3 February 24th 04 06:03 PM


All times are GMT +1. The time now is 10:28 AM.

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

About Us

"It's about Microsoft Excel"