Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

toolbar code can't find my macros

Posted on 2011-03-16
9
Medium Priority
?
261 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
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.

722 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