VBA 2010 Saving workshts-workbks new file
Closed
whitepanther
-
Aug 8, 2011 at 05:06 PM
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 - Aug 9, 2011 at 11:56 AM
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 - Aug 9, 2011 at 11:56 AM
Related:
- VBA 2010 Saving workshts-workbks new file
- Microsoft office 2010 free download - Download - Office suites
- Windows 10 iso file download 64-bit - Download - Windows
- Save as pdf office 2010 - Download - Other
- Kmspico zip file download - Download - Other
- Vba case like - Guide
1 response
rizvisa1
Posts
4478
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
May 5, 2022
766
Aug 9, 2011 at 11:56 AM
Aug 9, 2011 at 11:56 AM
How would one can say what sheet goes where. Presuming you know where, here is a sample code. The code would make use of a function MakeMultiStepDirectory. See the comments. You would have to download from there as no reason to reinvent the wheel
In the code below, idea is
In the code below, idea is
Sub test()
'Saving Individual worksheets as 97-2003 workbooks
Dim NewBook As Workbook
Dim OldBook As Workbook
Dim sh As Worksheet
Dim sPrintPath As String
Dim sOldPath As String
Dim sSavePath As String
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Set OldBook = Workbooks(ActiveWorkbook.Name)
sOldPath = OldBook.Path
sPrintPath = sOldPath & "\print\"
'the MakeMultiStepDirectory function can be found at (fix spaces)
'htt p: / / ww w.cpearson.com/excel/MakeDirMulti.aspx
Call MakeMultiStepDirectory(sPrintPath)
Application.DisplayAlerts = False
For Each sh In OldBook.Worksheets
If sh.Visible = True _
Then
Select Case sh.Name
Case "Sheet1", "Sheet2", "Sheet3"
sSavePath = sPrintPath
Case Else
sSavePath = sOldPath
End Select
sh.Copy
ActiveWorkbook.SaveAs Filename:=sSavePath & "\" & sh.Name & "", FileFormat:=xlWorkbookNormal
ActiveWorkbook.Close
End If
Next
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Application.DisplayAlerts = True
End Sub