View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default determining a Commndbar name from a cell

Set cTBar = CommandBars(strTBarName)

--
Regards,
Tom Ogilvy

"davegb" wrote in message
ps.com...
This macro is supposed to show a particular Commandbar by getting the
name, previously saved, from cell "E2" in the named spreadsheet. I'm
getting an "invalid use of property" error on the marked line. I've
tried about 6 different ways of coding this, but none of them have
worked.

Private Sub Workbook_Activate()
Dim strTBarName As String
strTBarName = Workbooks("PIP DD Template HideTbar.xls") _
.Worksheets("Macro Records").Range("E2").Value
Set cTBar.Name = strTBarName <---ERROR

cTBar.Visible = True

So I can't set the object's name, only the object. How do I make the
object be the one named in the referenced cell ("E2")?
Thanks for the help.