Solved

toolbar code can't find my macros

Posted on 2011-03-16
9
254 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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 3

Author Comment

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

ifinal-picerror.png
0
 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
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 use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

789 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