MrExcel Publishing
Your One Stop for Excel Tips & Solutions

adding Excel commands to button


Posted by Jim Sheldon on June 06, 2001 5:12 AM

I want to create a button that will run the FORM
command that is in the data menu in Excel 97 and attach
it to a specific spreadsheet.


Posted by Joe Was on June 06, 2001 5:29 AM

I think 97 works the same as 2000?

Use the macro recorder. Turn it on, do your FORM selection, turn off the recorder. Open the macro to edit remove the references to cell selection and other unnecessary Excel junk that was added. With macro options assign a hot-key or with View-Forms-toolbar select button draw it where you want it and select the macro you just edited to attach. If you can not get it to work, repost your code and I will fix it. JSW

Posted by Jim on June 06, 2001 6:09 AM

Re: I think 97 works the same as 2000?

I have copied the macro text, but when I try to run the macro
I get a "Run-Time error '1004' ShowDataForm method worksheet
class failed" message.

Sub OpenForm()
'
' OpenForm Macro
' Macro recorded 6/6/01 by Jim Sheldon
'

'
ActiveSheet.ShowDataForm
End Sub

Posted by Joe Was on June 06, 2001 8:03 AM

Rus, Try this


Try this, the use of DataForm requires a data range with a cell selected in that range. If not ShowDataForm fails! I will check and see if their is a work-around for this problem?

Sub OpenForm()
'
' OpenForm Macro
' Macro recorded 6/6/01 by Jim Sheldon
'

'
Worksheets(1).ShowDataForm

End Sub