calling VBA forms from a button in Excel
<p>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</p>

<pre><code>FormName.Show
</code></pre>

<p>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"</p>

<pre><code>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
</code></pre>

<p>This doesn't work, it created the button but when I click on the button I get</p>

<p>"Cannot run the macro "xxxx.xlam'!FormName.Show'  The macro may not be available in this workbook or all macros may be disabled.</p>

<p>Why does it work in the main macro but not in the button OnAction?</p>

<p>Thanks</p>