ONACTION macro tries to open another workbook
I have a userform in a book where you check a box called
Fillcolour(one of many checkboxes on the UserForm).
Then you press OK - this triggers the following macro:
Private Sub CmdOK_Click()
Me.Hide
Application.ScreenUpdating = False
Call AddMenuModifications
Unload Me
Application.ScreenUpdating = True
End Sub
Then in a normal module:
Sub AddMenuModifications()
On Error Resume Next
With CommandBars("Cell")
If UsrMenuBars.ChkFillColour Then
With .Controls.Add(msoControlButton)
.Caption = "Fill Colour"
.FaceId = 417
.OnAction = "ShowColorPallet"
End With
End If
End Sub
and in the same module:
Sub ShowColorPallet()
With Application.CommandBars("Fill Color")
.Top = 350
.Left = 500
.Visible = True
End With
End Sub
If I put just this code in a workbook on its own then it works fine -
but in the book I want it in, there are lots of bits of code like the
above which modify excel commandbars.
Anyhow when I press the new modifications excel opens another copy of
the workbook with the onaction code in it (or tries to - it tells me
I'm already in it, which I am!) - it then comes up with an error
message that just says "400"
Anyone ever seen this before??
Help greatly appreciated (I can forward the whole workbook if thats
any help)
Jason.
|