ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   SaveAs worksheets (https://www.excelbanter.com/excel-programming/388500-saveas-worksheets.html)

miek

SaveAs worksheets
 
Is there a way to save multiple worksheet as a new wookbook without having
the vba modules included with the save?

I currently am doing the following, but this saves the vba modules as well
as the
worksheets. I just want to save the work sheets.

Private Sub Save_Dialog()
Dim fd As FileDialog
Set fd = Application.FileDialog(msoFileDialogSaveAs)
Dim vrtSelectedItem As Variant
With fd
.Filters.Add "Excel", "*.xls; *.csv; *.csv", 2
If .Show = -1 Then 'user pressed action button.
.Execute
'Application.ActiveWorkbook.SaveCopyAs (vrtSelectedItem)
Else 'The user pressed Cancel.
End If
End With
Set fd = Nothing
End Sub

Norman Jones

SaveAs worksheets
 
Hi Niek,

To create a new workbook, try:

'=============
Public Sub Tester()
ActiveWorkbook.Worksheets.Copy
End Sub
'<<=============

Only code in the sheet modules ot the ThisWorkbook
modules will be carried to the new workbook.

If your intention is to delete all code, see Chip Pearson at:

Programming To The Visual Basic Editor
http://www.cpearson.com/excel/vbe.htm


---
Regards,
Norman



"miek" wrote in message
...
Is there a way to save multiple worksheet as a new wookbook without having
the vba modules included with the save?

I currently am doing the following, but this saves the vba modules as well
as the
worksheets. I just want to save the work sheets.

Private Sub Save_Dialog()
Dim fd As FileDialog
Set fd = Application.FileDialog(msoFileDialogSaveAs)
Dim vrtSelectedItem As Variant
With fd
.Filters.Add "Excel", "*.xls; *.csv; *.csv", 2
If .Show = -1 Then 'user pressed action button.
.Execute
'Application.ActiveWorkbook.SaveCopyAs (vrtSelectedItem)
Else 'The user pressed Cancel.
End If
End With
Set fd = Nothing
End Sub





All times are GMT +1. The time now is 08:38 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com