我已编写此代码将我的部分电子表格复制到新文件中,但原始文件中的所有宏都将作为原始文件的链接转到新文件。我想复制电子表格并在新文件中删除宏。请在下面找到我的代码,我该如何更改?
Sub IndRepPD()
Dim NewName As String
Dim nm As Name
Dim ws As Worksheet
If MsgBox("Are you sure you want to generate an Indidual Report for PD?" & vbCr & _
"The file will be saved as PD_VA2013_KPI in the same directory as the original." _
, vbYesNo, "Generate Individual Report for PD") = vbNo Then Exit Sub
With Application
.ScreenUpdating = False
On Error GoTo ErrCatcher
Sheets(Array("Inhalt", "PD", "PD Quality", "Glossary", "Status", "PD History")).Copy
On Error GoTo 0
For Each ws In ActiveWorkbook.Worksheets
ws.Cells.Copy
ws.[A1].PasteSpecial Paste:=xlPasteColumnWidths, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Cells(1, 1).Select
ws.Activate
Next ws
Cells(1, 1).Select
For Each nm In ActiveWorkbook.Names
nm.Delete
Next nm
ActiveWindow.DisplayWorkbookTabs = False
Worksheets("PD").Select
NewName = "PD_VA2013_KPI"
ActiveWorkbook.SaveCopyAs ThisWorkbook.Path & "\" & NewName & ".xls"
ActiveWorkbook.Close SaveChanges:=False
.ScreenUpdating = True
End With
Exit Sub
ErrCatcher:
MsgBox "Specified sheets do not exist within this workbook"
End Sub
答案 0 :(得分:0)
.xlsx不存储宏,但如果您使用电子表格中的按钮运行宏,则仍然存在指向原始文件宏的链接。