Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help on a button to export a specified sheet to a new xl file

Status
Not open for further replies.

Jhankins

Programmer
Jun 17, 2003
46
AU
I wish to create a button to export a selected sheet to a new workbook, all i wish them to enter a file name.
Can this be done??

 
Hi Jhankins,

goto this FAQ: faq707-2482

This should get you on the right track.

If you are moving the worksheet to a "new" workbook, then why should the user have to give a file name. Or did you mean "export a selected sheet to ANOTHER workbook"?

Peace! [peace]

Mike

Never say Never!!!
Nothing is impossible!!!
 
Use the control toolbox toolbar to draw a command button on your workbook - I have left t as command button 1, rename it to whatever you like, but if you do you'll have to edit the code below.

In design mode double click on the button and insert the code below into the shell code.

Take design mode off and the button should work.

[tt]Dim varSaveName As Variant, wbkActive As Workbook, shpSearch As Shape
Set wbkActive = ActiveWorkbook
varSaveName = Application.GetSaveAsFilename(Filefilter:="Excel Workbooks (*.xls),*.xls")
If varSaveName = False Then Exit Sub
ActiveSheet.Copy
For Each shpSearch In ActiveSheet.Shapes
If shpSearch.Name = "CommandButton1" Then shpSearch.Delete
Next
ActiveWorkbook.SaveAs (varSaveName)
wbkActive.Activate[/tt]

 
Cheers,

Thanks for the help worked a treat.


Kodus to you all.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top