0

あるワークシートを別のワークシートにコピーして値のみを貼り付ける次のコードがありますが、シートを保護するコードが機能していませんか? ここで何が間違っていますか?

Sub GetQuote()

    Range("AK548").Select
    Selection.Copy
    Range("AK549").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False

    Dim ws As Worksheet
    Dim sDataOutputName As String

    With Application
        .Cursor = xlWait
        .StatusBar = "Saving Quote & Proposal Sheet..."
        .ScreenUpdating = False

         '       Copy specific sheets
         '       *SET THE SHEET NAMES TO COPY BELOW*
         '       Array("Sheet Name", "Another sheet name", "And Another"))
         '       Sheet names go inside quotes, seperated by commas
        On Error GoTo ErrCatcher
        Sheets(Array("Quote & Proposal")).Copy
        On Error GoTo 0

         '       Paste sheets as values
         '       Remove External Links, Hperlinks and hard-code formulas
         '       Make sure A1 is selected on all sheets
        For Each ws In ActiveWorkbook.Worksheets
            ws.Cells.Copy
            ws.[A1].PasteSpecial Paste:=xlValues
            ws.Cells.Hyperlinks.Delete
            Application.CutCopyMode = False
            Cells(1, 1).Select
            ws.Activate
        Next ws
        Cells(1, 1).Select

        sDataOutputName = ThisWorkbook.Path & "\" & ThisWorkbook.Worksheets("Quote Questions").Range("AK545").Value & ".xlsx"

         '       Save it with the NewName and in the same directory as original
        ActiveWorkbook.SaveCopyAs sDataOutputName
        ActiveWorkbook.Protect Password:="12345"
        ActiveWorkbook.Close SaveChanges:=False

        .Cursor = xlDefault
        .StatusBar = False
        .ScreenUpdating = True
    End With
    Exit Sub

ErrCatcher:
    MsgBox "Specified sheets do not exist within this workbook"
End Sub
4

3 に答える 3