Sub EX()
Dim Sht As Worksheet, xB As Workbook, N%
Application.ScreenUpdating = False
Set xB = Workbooks.Add
ThisWorkbook.Activate
For Each Sht In Sheets(Array("報價單", "請款單"))
With Sht.Cells: .Locked = True: .FormulaHidden = True: End With
Sht.Protect: N = N + 1
With xB.Sheets(N): Sht.Cells.Copy .[A1]: .Name = Sht.Name: End With
Sht.Unprotect
Next
xB.SaveAs ThisWorkbook.Path & "\" & Format(Now, "yyyymmddhhmmss") & [查表!C4], CreateBackup:=False
xB.Close
End Sub
可能版本不同的關係吧! 我是用2000版,
那就多一行刪物件:
Sub EX()
Dim Sht As Worksheet, xB As Workbook, N%
Application.ScreenUpdating = False
Set xB = Workbooks.Add
ThisWorkbook.Activate
For Each Sht In Sheets(Array("報價單", "請款單"))
With Sht.Cells: .Locked = True: .FormulaHidden = True: End With
Sht.Protect: N = N + 1
With xB.Sheets(N)
Sht.Cells.Copy .[A1]
.Name = Sht.Name
.DrawingObjects.Delete '刪除物件
End With
Sht.Unprotect
Next
xB.SaveAs ThisWorkbook.Path & "\" & Format(Now, "yyyymmddhhmmss") & [查表!C4], CreateBackup:=False
xB.Close
End Sub
Sub EX3()
Dim FN$, Sht As Worksheet, xB As Workbook
FN = ThisWorkbook.Path & "\" & Format(Now, "yyyymmddhhmmss") & [查表!C4]
Set xB = Workbooks.Add
For Each Sht In ThisWorkbook.Sheets(Array("報價單", "請款單"))
Sht.Copy Before:=xB.Sheets(1)
With xB.Sheets(1)
.UsedRange.Value = .UsedRange.Value
.DrawingObjects.Delete
End With
Next
xB.SaveAs FN, CreateBackup:=False: xB.Close
End Sub