My code copies a table, processes the copied data, copies another table, processes the copied data and so on ...
The problem is that sometimes some tables have a lot of data that take a long time to be copied, causing an error in the try/catch block.
Is there a way to start processing the copied data only after the data is ready on the clipboard?
Private Sub Copy
Clipboard.Clear()
Try
Win32.SetCursorPos(200,200)
Win32.mouse_event(Win32.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
Win32.mouse_event(Win32.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
SendKeys.SendWait("^C")
Catch ex As Exception
Msgbox (ex.message)
End Try
'PROCESS THE COPIED DATA
Try
Dim clip() As String
Dim col() As String
clip = Clipboard.GetText().Split(Environment.NewLine)
col = clip(i).Split(vbTab)
'I test the data to see if it interests me
Catch ex As Exception
End Try
Clipboard.Clear()
Try
Win32.SetCursorPos(600,200)
Win32.mouse_event(Win32.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
Win32.mouse_event(Win32.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
SendKeys.SendWait("^C")
Catch ex As Exception
Msgbox (ex.message)
End Try
'PROCESS THE COPIED DATA
Clipboard.Clear()
Try
Win32.SetCursorPos(400,200)
Win32.mouse_event(Win32.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
Win32.mouse_event(Win32.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
SendKeys.SendWait("^C")
Catch ex As Exception
Msgbox (ex.message)
End Try
'PROCESS THE COPIED DATA
End Sub