-1

这是我的宏代码。所做的是将特定工作表复制到另一个工作簿。我的问题是如何只粘贴值并且格式必须是只读类型。

Sub NewReport()
Dim PRICE_REV_TEMPLATE As Workbook
Dim PRICE_REV_TEMPLATE_FC As Workbook

With Application
    .ScreenUpdating = False
    .DisplayAlerts = False
    .EnableEvents = False
End With

Set PRICE_REV_TEMPLATE = ActiveWorkbook


Set PRICE_REV_TEMPLATE_FC = Application.Workbooks.Add(1)
PRICE_REV_TEMPLATE.Sheets(Array(PRICE_REV_TEMPLATE.Sheets(6).Name)).Copy _         
Before:=PRICE_REV_TEMPLATE_FC.Sheets(1)
PRICE_REV_TEMPLATE_FC.SaveAs FileName:="C:\Users\A3RBJZZ\Desktop\PRICE_REV_TEMPLATE_FC"

PRICE_REV_TEMPLATE_FC.Close
With Application
    .ScreenUpdating = True
    .DisplayAlerts = True
    .EnableEvents = True
End With
End Sub
4

1 回答 1

0

试试这个 - 希望这会有所帮助

Sub NewReport()
   Dim PRICE_REV_TEMPLATE As Workbook
   Dim PRICE_REV_TEMPLATE_FC As Workbook

   With Application
    .ScreenUpdating = False
    .DisplayAlerts = False
    .EnableEvents = False
   End With

   Set PRICE_REV_TEMPLATE = ActiveWorkbook


   Set PRICE_REV_TEMPLATE_FC = Application.Workbooks.Add(1)
   PRICE_REV_TEMPLATE.Sheets(Array(PRICE_REV_TEMPLATE.Sheets(1).Name)).Copy Before:=PRICE_REV_TEMPLATE_FC.Sheets(1)

   'selecting all cells and pasting as only values
    PRICE_REV_TEMPLATE_FC.ActiveSheet.Cells.Select
    Selection.Copy
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
    PRICE_REV_TEMPLATE_FC.ActiveSheet.Paste
    Application.CutCopyMode = False

    'Added the Readonlyrecommended attrib.
    PRICE_REV_TEMPLATE_FC.SaveAs Filename:="C:\Users\A3RBJZZ\Desktop\PRICE_REV_TEMPLATE_FC", ReadOnlyRecommended:=True

    PRICE_REV_TEMPLATE_FC.Close
    With Application
      .ScreenUpdating = True
      .DisplayAlerts = True
      .EnableEvents = True
    End With
End Sub
于 2013-08-12T05:06:20.903 回答