I have a macro that parses through a large file in Excel. I created a form that allows me to search for and provide a summary of specific messages. I can put
FormName.Show
at the end of the macro and it works. The form displays as the parsing macro completes. But I don't always want the form to appear and sometimes I want to call it again after I've saved the spreadsheet. So I wrote another function that can create a button that can open the form. In the .OnAction statement I have OnAction = "FormName.Show"
Sub Create_Button()
ActiveSheet.Buttons.Add(437.25, 72, 125.25, 47.25).Select
Selection.OnAction = "FormName.Show"
Selection.Characters.Text = "Search Messages"
End Sub
This doesn't work, it created the button but when I click on the button I get
"Cannot run the macro "xxxx.xlam'!FormName.Show' The macro may not be available in this workbook or all macros may be disabled.
Why does it work in the main macro but not in the button OnAction?
Thanks
