Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default OnAction Cannot find Macro ??

Hi all

I'm new to VBA and am trying to add my macro to a menu

I've created the menu fine but no matter what I try the OnAction for the
menu item says it cannot find the marco ?? even when it is in the
ThisWorkbook module and not in a separate module file ??

I've tried evreything I can think of, Starting again cut 'n' paste etc and I
just cannot get it to find the macro that just has the MyForm.Show in it !!
??. I even tried putting this directly into the OnAction but no luck

TIA

Andrew Kennard


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default OnAction Cannot find Macro ??

Andrew,

It would help to see the code, but you should put the macro in a standard
module, not in ThisWorkbook.

Show us the macro, and the code that creates a menu.


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Andrew Kennard" wrote in message
...
Hi all

I'm new to VBA and am trying to add my macro to a menu

I've created the menu fine but no matter what I try the OnAction for the
menu item says it cannot find the marco ?? even when it is in the
ThisWorkbook module and not in a separate module file ??

I've tried evreything I can think of, Starting again cut 'n' paste etc and

I
just cannot get it to find the macro that just has the MyForm.Show in it

!!
??. I even tried putting this directly into the OnAction but no luck

TIA

Andrew Kennard




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default OnAction Cannot find Macro ??

Thanks for your generous offer Bob. The code is as follows :-

ThisWorkBook Code
-------------------------------

Private Sub WorkBook_Open()

Dim cbWSMenuBar As CommandBar
Dim Ctrl As CommandBarControl, muCustom As CommandBarControl
Dim iHelpIndex As Integer

Set cbWSMenuBar = Application.CommandBars("Worksheet menu bar")
iHelpIndex = cbWSMenuBar.Controls("Help").Index

Set muCustom = cbWSMenuBar.Controls.Add(Type:=msoControlPopup, _
Befo=iHelpIndex, Temporary:=True)
For Each Ctrl In cbWSMenuBar.Controls
If Ctrl.Caption = "&ServeBase" Then
cbWSMenuBar.Controls("ServeBase").Delete
End If
Next Ctrl

With muCustom
.Caption = "&ServeBase"
With .Controls.Add(Type:=msoControlButton)
.Caption = "&Import and Format"
.OnAction = "ImportFormat"
End With
With .Controls.Add(Type:=msoControlButton)
.Caption = "Print Batch"
.OnAction = "PrintBatch"
End With
End With

End Sub

-------------------------------------------
Module Code

Sub ImportFormat()
Import1.Show
End Sub
----------------------------------------------

It's probably something really obvious but I can't see it ! ;)

BTW the actual error is "The Macro gg7.xls!ImportFormat cannot be found"

TIA

Andrew Kennard

"Bob Phillips" wrote in message
...
Andrew,

It would help to see the code, but you should put the macro in a standard
module, not in ThisWorkbook.

Show us the macro, and the code that creates a menu.


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Andrew Kennard" wrote in message
...
Hi all

I'm new to VBA and am trying to add my macro to a menu

I've created the menu fine but no matter what I try the OnAction for the
menu item says it cannot find the marco ?? even when it is in the
ThisWorkbook module and not in a separate module file ??

I've tried evreything I can think of, Starting again cut 'n' paste etc
and

I
just cannot get it to find the macro that just has the MyForm.Show in it

!!
??. I even tried putting this directly into the OnAction but no luck

TIA

Andrew Kennard






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default OnAction Cannot find Macro ??

Andrew,

I just plugged the code in, and it worked fine for me.

What you sometimes find is that you get that error if there is a run time
error in the code, rather than the actual error, you get a not found error.

Are you sure you have named the Userform Import1. One way to check for these
errors is to run the macro ImportFormat directly, not from the button. If
there is a code error, it will highlight the actual error.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Andrew Kennard" wrote in message
...
Thanks for your generous offer Bob. The code is as follows :-

ThisWorkBook Code
-------------------------------

Private Sub WorkBook_Open()

Dim cbWSMenuBar As CommandBar
Dim Ctrl As CommandBarControl, muCustom As CommandBarControl
Dim iHelpIndex As Integer

Set cbWSMenuBar = Application.CommandBars("Worksheet menu bar")
iHelpIndex = cbWSMenuBar.Controls("Help").Index

Set muCustom = cbWSMenuBar.Controls.Add(Type:=msoControlPopup, _
Befo=iHelpIndex, Temporary:=True)
For Each Ctrl In cbWSMenuBar.Controls
If Ctrl.Caption = "&ServeBase" Then
cbWSMenuBar.Controls("ServeBase").Delete
End If
Next Ctrl

With muCustom
.Caption = "&ServeBase"
With .Controls.Add(Type:=msoControlButton)
.Caption = "&Import and Format"
.OnAction = "ImportFormat"
End With
With .Controls.Add(Type:=msoControlButton)
.Caption = "Print Batch"
.OnAction = "PrintBatch"
End With
End With

End Sub

-------------------------------------------
Module Code

Sub ImportFormat()
Import1.Show
End Sub
----------------------------------------------

It's probably something really obvious but I can't see it ! ;)

BTW the actual error is "The Macro gg7.xls!ImportFormat cannot be found"

TIA

Andrew Kennard

"Bob Phillips" wrote in message
...
Andrew,

It would help to see the code, but you should put the macro in a

standard
module, not in ThisWorkbook.

Show us the macro, and the code that creates a menu.


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Andrew Kennard" wrote in message
...
Hi all

I'm new to VBA and am trying to add my macro to a menu

I've created the menu fine but no matter what I try the OnAction for

the
menu item says it cannot find the marco ?? even when it is in the
ThisWorkbook module and not in a separate module file ??

I've tried evreything I can think of, Starting again cut 'n' paste etc
and

I
just cannot get it to find the macro that just has the MyForm.Show in

it
!!
??. I even tried putting this directly into the OnAction but no luck

TIA

Andrew Kennard








  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default OnAction Cannot find Macro ??

Yes If I put the cursor in the Sub ImportFormat and click run .... my form
shows

"Bob Phillips" wrote in message
...
Andrew,

I just plugged the code in, and it worked fine for me.

What you sometimes find is that you get that error if there is a run time
error in the code, rather than the actual error, you get a not found
error.

Are you sure you have named the Userform Import1. One way to check for
these
errors is to run the macro ImportFormat directly, not from the button. If
there is a code error, it will highlight the actual error.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Andrew Kennard" wrote in message
...
Thanks for your generous offer Bob. The code is as follows :-

ThisWorkBook Code
-------------------------------

Private Sub WorkBook_Open()

Dim cbWSMenuBar As CommandBar
Dim Ctrl As CommandBarControl, muCustom As CommandBarControl
Dim iHelpIndex As Integer

Set cbWSMenuBar = Application.CommandBars("Worksheet menu bar")
iHelpIndex = cbWSMenuBar.Controls("Help").Index

Set muCustom = cbWSMenuBar.Controls.Add(Type:=msoControlPopup, _
Befo=iHelpIndex, Temporary:=True)
For Each Ctrl In cbWSMenuBar.Controls
If Ctrl.Caption = "&ServeBase" Then
cbWSMenuBar.Controls("ServeBase").Delete
End If
Next Ctrl

With muCustom
.Caption = "&ServeBase"
With .Controls.Add(Type:=msoControlButton)
.Caption = "&Import and Format"
.OnAction = "ImportFormat"
End With
With .Controls.Add(Type:=msoControlButton)
.Caption = "Print Batch"
.OnAction = "PrintBatch"
End With
End With

End Sub

-------------------------------------------
Module Code

Sub ImportFormat()
Import1.Show
End Sub
----------------------------------------------

It's probably something really obvious but I can't see it ! ;)

BTW the actual error is "The Macro gg7.xls!ImportFormat cannot be found"

TIA

Andrew Kennard

"Bob Phillips" wrote in message
...
Andrew,

It would help to see the code, but you should put the macro in a

standard
module, not in ThisWorkbook.

Show us the macro, and the code that creates a menu.


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Andrew Kennard" wrote in message
...
Hi all

I'm new to VBA and am trying to add my macro to a menu

I've created the menu fine but no matter what I try the OnAction for

the
menu item says it cannot find the marco ?? even when it is in the
ThisWorkbook module and not in a separate module file ??

I've tried evreything I can think of, Starting again cut 'n' paste etc
and
I
just cannot get it to find the macro that just has the MyForm.Show in

it
!!
??. I even tried putting this directly into the OnAction but no luck

TIA

Andrew Kennard












  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default OnAction Cannot find Macro ??

Then I am at a loss for the moment Andrew.

Would you like to send me your workbook, and I will take a look?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Andrew Kennard" wrote in message
...
Yes If I put the cursor in the Sub ImportFormat and click run .... my form
shows

"Bob Phillips" wrote in message
...
Andrew,

I just plugged the code in, and it worked fine for me.

What you sometimes find is that you get that error if there is a run

time
error in the code, rather than the actual error, you get a not found
error.

Are you sure you have named the Userform Import1. One way to check for
these
errors is to run the macro ImportFormat directly, not from the button.

If
there is a code error, it will highlight the actual error.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Andrew Kennard" wrote in message
...
Thanks for your generous offer Bob. The code is as follows :-

ThisWorkBook Code
-------------------------------

Private Sub WorkBook_Open()

Dim cbWSMenuBar As CommandBar
Dim Ctrl As CommandBarControl, muCustom As CommandBarControl
Dim iHelpIndex As Integer

Set cbWSMenuBar = Application.CommandBars("Worksheet menu bar")
iHelpIndex = cbWSMenuBar.Controls("Help").Index

Set muCustom = cbWSMenuBar.Controls.Add(Type:=msoControlPopup, _
Befo=iHelpIndex, Temporary:=True)
For Each Ctrl In cbWSMenuBar.Controls
If Ctrl.Caption = "&ServeBase" Then
cbWSMenuBar.Controls("ServeBase").Delete
End If
Next Ctrl

With muCustom
.Caption = "&ServeBase"
With .Controls.Add(Type:=msoControlButton)
.Caption = "&Import and Format"
.OnAction = "ImportFormat"
End With
With .Controls.Add(Type:=msoControlButton)
.Caption = "Print Batch"
.OnAction = "PrintBatch"
End With
End With

End Sub

-------------------------------------------
Module Code

Sub ImportFormat()
Import1.Show
End Sub
----------------------------------------------

It's probably something really obvious but I can't see it ! ;)

BTW the actual error is "The Macro gg7.xls!ImportFormat cannot be

found"

TIA

Andrew Kennard

"Bob Phillips" wrote in message
...
Andrew,

It would help to see the code, but you should put the macro in a

standard
module, not in ThisWorkbook.

Show us the macro, and the code that creates a menu.


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Andrew Kennard" wrote in message
...
Hi all

I'm new to VBA and am trying to add my macro to a menu

I've created the menu fine but no matter what I try the OnAction for

the
menu item says it cannot find the marco ?? even when it is in the
ThisWorkbook module and not in a separate module file ??

I've tried evreything I can think of, Starting again cut 'n' paste

etc
and
I
just cannot get it to find the macro that just has the MyForm.Show

in
it
!!
??. I even tried putting this directly into the OnAction but no luck

TIA

Andrew Kennard












Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro - onAction arguments version83 Excel Worksheet Functions 2 April 10th 10 09:59 PM
.ONACTION macro call fails Wayne Excel Discussion (Misc queries) 2 March 2nd 05 05:10 PM
VBE Custom menuitem not calling OnAction macro R Avery Excel Programming 4 July 13th 04 10:39 PM
Find OnAction property Kemosabe Excel Programming 1 November 21st 03 03:34 PM
ONACTION macro tries to open another workbook jason Excel Programming 2 October 30th 03 10:12 PM


All times are GMT +1. The time now is 04:30 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"