Programming behind a button

  • Thread starter Thread starter DRE
  • Start date Start date
D

DRE

I need to have a button in an execl file that when clicked
will save the modifications made and then save the file as
an html file on a server to be viewed as a web page. I
know that all you have to do is click "save as html" but
we don't want the users to have to learn to do that.

Thanks in advance for any help.
 
One method would be to add the button to the tool bar. I believe Save to
Web has it's own button. This would need to be set on each PC or the file
would need code that would add the button when it is opened.

Another method would be to record a macro of you doing the key strokes and
then attach that maco to a button or shape. To record a macro, selecect
Tools, Macro, Record Macro, name it if you wish, record the keystrokes then
stop the recording by clicking on the square stop button. On your
worksheet, add a button, a shape or add a picture. Then right click on it
and select Assign Macro. Choose the macro you recorded and that should do
it.

FYI - this is the code that was created when I recorded the macro. Note
that this method "hard codes" the file name. If you want to prompt the user
for a new file name, you'll need some more code.

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 7/18/2003 by John A Michl
'

'
ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and Settings\John\My Documents\Book1.htm",
FileFormat:=xlHtml, _
ReadOnlyRecommended:=False, CreateBackup:=False
End Sub

Good luck
John Michl
www.johnmichl.com
 
DRE,

The easy way is to "record" a macro to do exactly what you want.
Tools/Macro/Record New Macro
When done, use a CommandButton from the "Forms" menu
View/Toolbars/Forms
When you drag the button to your worksheet, you'll be promted to
assign a macro to it. Assign the one you just recorded.
Every time the user presses the button, it'll do exactly what you
recorded in the macro.

John
 
Back
Top