如何压制Excel剪贴板邮件的大信息

我正在复制工作表ws中的数据,并试图只将值粘贴回原始工作表,从而用纯文本覆盖原始数据。 当我closures工作簿时,我得到了一个excel信息,告诉我“剪贴板上有大量的信息,你想把这些信息放到另一个程序中吗? 我永远不会想这样做。 我不希望这个消息不出现或者假设答案是“否”。

Function FindPresenters(MyDate As Date, MyWS As String) As String 'MyDate is in format of 10/3/2016 'MyWS is the target worksheet to find MyDate Dim GCell As Range Dim xlApp As Object Dim WB As Workbook Dim WS As Worksheet Dim MyLoop As Integer Dim Found As Boolean On Error GoTo ErrorHandler Set xlApp = CreateObject("Excel.application") 'New Excel.Application Application.ScreenUpdating = True xlApp.Visible = True Set WB = xlApp.Workbooks.Open ("Sched(Others).xlsx") Set WS = WB.Worksheets("Oct 2016 Training Schedule") With WS '.UsedRange '.Cells.Select .UsedRange.Select .Cells.Copy .Cells.PasteSpecial Paste:=xlPasteValues, _ Operation:=xlNone, SkipBlanks:=False, Transpose:=False Application.CutCopyMode = False 'This should suppress msg, but doesn't .Range("B2").Select End With WS.Activate Set GCell = WS.Cells.Find(MyDate) Found = False For MyLoop = 1 To MaxDayItems 'Find the entrees for the month Debug.Print GCell.Offset(MyLoop, 0).Text If Not Found And InStr(1, GCell.Offset(MyLoop, 0).Text, "CO") > 0 Then 'Found data Found = True FindPresenters = GCell.Offset(MyLoop, 0).Text MyLoop = MaxDayItems + 1 'Terminate searching End If Next MyLoop Done: Application.DisplayAlerts = False 'Tried this to suppress the message WB.Close True 'This is where the Clipboard error appears Application.DisplayAlerts = True Application.ScreenUpdating = True Set WS = Nothing Set WB = Nothing xlApp.Quit Set xlApp = Nothing Exit Function 'Error Handling section. ErrorHandler: ... GoTo Done End Function 

由于要复制的单元格属于xlApp (Excel.Application的单独实例),因此您需要使xlApp.CutCopyMode等于false。

 xlApp.CutCopyMode = False 

我同意共产国际的评论:“你只是粘贴价值观 – 直接写下来”

看起来你很容易用工作表中的所有公式replace工作表中的所有公式。 这可以通过这样简单地实现:

 WS.UsedRange.Value = WS.UsedRange.Value