Solved

toolbar code can't find my macros

Posted on 2011-03-16
9
251 Views
Last Modified: 2012-05-11
excel vba,

I have used the ciode below in reference to another question:

http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/Excel/Q_23184174.html#a35148450

I keep getting a   <sheetname>!OpenPrebuilts   macro not found

 ??







Sub SetUpCbars()
    Dim ctl As CommandBarControl
    On Error Resume Next
    Set cbr = Application.CommandBars(gcstrAPP_NAME)
    If Not cbr Is Nothing Then Exit Sub
    Set cbr = Application.CommandBars.Add(Name:=gcstrAPP_NAME, Position:=msoBarFloating, MenuBar:=False, temporary:=True)
    Set ctl = cbr.Controls.Add(Type:=msoControlButton)
    With ctl
        .Caption = "Prebuilts"
        .OnAction = "OpenPrebuilts"
        .Style = msoButtonCaption
    End With
    Set ctl = cbr.Controls.Add(Type:=msoControlButton)
    With ctl
        .Caption = "Extended Search"
        .OnAction = "OpenExtSearch"
        .Style = msoButtonCaption
    End With
    Set ctl = cbr.Controls.Add(Type:=msoControlButton)
    With ctl
        .Caption = "Reset Project"
        .OnAction = "ResetProject"
        .Style = msoButtonCaption
    End With
    cbr.Visible = True
End Sub
Sub CleanUpCBars()
    On Error Resume Next
    Application.CommandBars(gcstrAPP_NAME).Delete
End Sub
Sub HideBar()
   On Error Resume Next
   Application.CommandBars(gcstrAPP_NAME).Visible = False
End Sub
Sub ShowBar()
   On Error Resume Next
   Application.CommandBars(gcstrAPP_NAME).Visible = True
End Sub
Sub OpenExtSearch()
frmExpSearch.Show
Sheets("sheet1").Activate
 ' to be considered for error entry
 ActiveCell.Offset(0, 0).Select
'frmiCart.Show
End Sub

Sub OpenPrebuilts()
frmPrebuilts.Show
End Sub

Sub ResetProject()
Dim mysheet As Worksheet

' STILL INVESTIGATING. THIS CAUSES HAVOC FOR SOME REASON
'ThisWorkbook.Names("DeleteData").RefersToRange = ""
   ' SIMPLE BUT WORKS
  ' new code 01-06-2006
' make sure first
    Application.ScreenUpdating = False
    Application.EnableEvents = False
'Range("A2:AP65536").Select
 ' temp unprotect
' get rid of the data
  ActiveSheet.Unprotect
   Rows("2:65000").Select
     Selection.ClearFormats
     Selection.ClearContents
          Selection.NumberFormat = "@"
' wrap text richtext description
FormatCellsTest
' Protect Sheet Again
'  ProtectColumns
    Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub

Open in new window

0
Comment
Question by:fordraiders
  • 6
  • 3
9 Comments
 
LVL 85

Expert Comment

by:Rory Archibald
ID: 35148614
Where is that code located?
0
 
LVL 3

Author Comment

by:fordraiders
ID: 35148866
WORKBOOK OPEN EVENT



had This on a module1
Sub OpenExtSearch()
frmExpSearch.Show
Sheets("sheet1").Activate
 ' to be considered for error entry
 ActiveCell.Offset(0, 0).Select
'frmiCart.Show
End Sub

Sub OpenPrebuilts()
frmPrebuilts.Show
End Sub

Sub ResetProject()
Dim mysheet As Worksheet

' STILL INVESTIGATING. THIS CAUSES HAVOC FOR SOME REASON
'ThisWorkbook.Names("DeleteData").RefersToRange = ""
   ' SIMPLE BUT WORKS
  ' new code 01-06-2006
' make sure first
    Application.ScreenUpdating = False
    Application.EnableEvents = False
'Range("A2:AP65536").Select
 ' temp unprotect
' get rid of the data
  ActiveSheet.Unprotect
   Rows("2:65000").Select
     Selection.ClearFormats
     Selection.ClearContents
          Selection.NumberFormat = "@"
' wrap text richtext description
FormatCellsTest
' Protect Sheet Again
'  ProtectColumns
    Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub
0
 
LVL 85

Expert Comment

by:Rory Archibald
ID: 35148907
Try this:
Sub SetUpCbars()  
    Dim ctl As CommandBarControl  
    On Error Resume Next  
    Application.CommandBars(gcstrAPP_NAME).Delete
    On Error Goto 0
    Set cbr = Application.CommandBars.Add(Name:=gcstrAPP_NAME, Position:=msoBarFloating, MenuBar:=False, temporary:=True)  
    Set ctl = cbr.Controls.Add(Type:=msoControlButton)  
    With ctl  
        .Caption = "Prebuilts"  
        .OnAction = "'" & thisworkbook.name & "'!OpenPrebuilts"  
        .Style = msoButtonCaption  
    End With  
    Set ctl = cbr.Controls.Add(Type:=msoControlButton)  
    With ctl  
        .Caption = "Extended Search"  
        .OnAction = "'" & thisworkbook.name & "'!OpenExtSearch"  
        .Style = msoButtonCaption  
    End With  
    Set ctl = cbr.Controls.Add(Type:=msoControlButton)  
    With ctl  
        .Caption = "Reset Project"  
        .OnAction = "'" & thisworkbook.name & "'!ResetProject"  
        .Style = msoButtonCaption  
    End With  
    cbr.Visible = True  
End Sub  

Open in new window


I assume you have set the gcstrAPP_NAME constant somewhere?
0
 
LVL 3

Author Comment

by:fordraiders
ID: 35149372
rorya,
here is what it is saying

ifinal-picerror.png
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 3

Author Comment

by:fordraiders
ID: 35149413
rorrya,

"thisworkbook"

Option Explicit
Public mMfrnumSelect As Boolean
Private cbr As CommandBar
Private Const gcstrAPP_NAME As String = "iFinal_ToolBar_Menu"

Won't take
Public Const gcstrAPP_NAME As String = "iFinal_ToolBar_Menu"


0
 
LVL 3

Author Comment

by:fordraiders
ID: 35149751
ok put the subs in Sheet1...

changed the 3 lines codes:
.OnAction = "'" & ThisWorkbook.Name & "'!Sheet1.OpenPrebuilts"

Added sheet1.<name of macro>


0
 
LVL 3

Author Comment

by:fordraiders
ID: 35149758
post answer back and I'll close it ...
0
 
LVL 85

Accepted Solution

by:
Rory Archibald earned 500 total points
ID: 35149931
FYI, this line:
Public Const gcstrAPP_NAME As String = "iFinal_ToolBar_Menu"


should be in a normal module, not in the ThisWorkbook module.
0
 
LVL 3

Author Closing Comment

by:fordraiders
ID: 35151127
Thanks !
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

What is a Form List Box? (skip if you know this) The forms List Box is the alternative to the ActiveX list box. If you are using excel 2007, you first make sure you have a developer tab (click the Orb)->"Excel Options"->Popular->"Show Developer tab…
Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now