Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / January 2006

Tip: Looking for answers? Try searching our database.

Stumped by "Object variable not set" again

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
davegb - 25 Jan 2006 16:30 GMT
I have code that shows a specific commanbar when a particular worksheet
is activated, then hides the commandbar when the spreadsheet  is
de-selected. I want to save the commandbar name so that when the
spreadsheet is closed, the last commandbar will be hidden. But I'm
getting the ever-present "Object or withblock variable not set" error.
Here is the sheet code:

Private Sub Worksheet_Activate()

Application.CommandBars("Abuse").Visible = True
cTBar.Name = "Abuse"<----ERROR
Call TBarNameSave

End Sub

cTBar is publicly declared as a Commandbar. So why won't it accept the
name?
Thanks.
Bob Phillips - 25 Jan 2006 16:42 GMT
Declaring it as type Commandbar does not make it a commandbar, it just means
that it can be set to a commandbar via code, just declaring leaves it as
Nothing.

I don't think I fully understand what you are trying to do?

--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

> I have code that shows a specific commanbar when a particular worksheet
> is activated, then hides the commandbar when the spreadsheet  is
[quoted text clipped - 14 lines]
> name?
> Thanks.
Jim Thomlinson - 25 Jan 2006 16:45 GMT
Objects need to be set, even if they are publicly declared. Give this a
whirl...

Private Sub Worksheet_Activate()

set cTBar = Application.CommandBars("Abuse")
cTBar.Visible = True
cTBar.Name = "Abuse"
Call TBarNameSave

End Sub

Signature

HTH...

Jim Thomlinson

> I have code that shows a specific commanbar when a particular worksheet
> is activated, then hides the commandbar when the spreadsheet  is
[quoted text clipped - 14 lines]
> name?
> Thanks.
davegb - 25 Jan 2006 17:05 GMT
Thanks for both of your replies.
Your solution worked, Jim. And I eliminated the cTBar.Name="Abuse" line
as no longer necessary.

> Objects need to be set, even if they are publicly declared. Give this a
> whirl...
[quoted text clipped - 31 lines]
> > name?
> > Thanks.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.