Remove warning for clipboard large amount of data

gailb
3StarLounger
Posts: 254
Joined: 09 May 2020, 14:00

Remove warning for clipboard large amount of data

Post by gailb »

I have a folder of files which I'm opening and copying out data. All of this works fine except for the warning dialogue for data on the clipboard.

I've tried to add the applications to disable the events, but this still does not suppress the message. Do I simply have something out of place?

Code: Select all

Sub OpenOtherFile()
    
    Dim OneDrivePath    As String
    Dim wb1             As Workbook: Set wb1 = ActiveWorkbook
    Dim wb2             As Workbook
    Dim File            As Object
    Dim strPath         As String
    Dim strFile         As String
    Dim strFile2        As String
    
    Application.ScreenUpdating = False
    OneDrivePath = ThisWorkbook.Path & "\"
    If OneDrivePath Like "https:*" Then
        OneDrivePath = Replace(Environ("OneDrive") & "\" & Split(OneDrivePath, "/", 5)(4), "/", "\")
    End If
    
    For Each File In CreateObject("Scripting.FileSystemobject").Getfolder(OneDrivePath).Files
        If File.Name Like "CBM*" Then
            Set wb2 = Workbooks.Open(File)
            strPath = File
            strFile = Right(strPath, Len(strPath) - InStrRev(strPath, "\"))
            strFile2 = Left(strFile, Application.WorksheetFunction.Find(".", strFile) - 1)
            wb2.Sheets("Measurement Sheet").Range("D2:I868").SpecialCells(xlVisible).Copy
            Application.Goto wb1.Sheets(strFile2).Range("A1"), scroll:=True
            wb1.Sheets(strFile2).Range("E2").PasteSpecial (xlPasteValues)
            Application.EnableEvents = False
            wb2.Close False
            Application.CutCopyMode = False
            Application.EnableEvents = True
        End If
    Next File
    Application.ScreenUpdating = True

End Sub

gailb
3StarLounger
Posts: 254
Joined: 09 May 2020, 14:00

Re: Remove warning for clipboard large amount of data

Post by gailb »

Nevermind, figured it out. I was using EnableEvents when I actually needed DisplayAlerts.

User avatar
rory
5StarLounger
Posts: 817
Joined: 24 Jan 2010, 15:56

Re: Remove warning for clipboard large amount of data

Post by rory »

Or put the CutCopyMode line above the line that closes the workbook.
Regards,
Rory

gailb
3StarLounger
Posts: 254
Joined: 09 May 2020, 14:00

Re: Remove warning for clipboard large amount of data

Post by gailb »

Thanks Rory