I extract data from SAP to excel, I do this:
- the transaction runs automatically in SAP GUI, then saves the data in a txt file
- VBA reads my txt file
- Glue it in an Excel temp sheet and then in my table
- The problem is that sometimes I don't have any data, because SAP doesn't find any except that it comes to paste the data of the previous transaction (as I have several transactions to perform) what I wanted to solve my problem is that I want to make a loop "If my data in the clipboard are the same as the temp sheet, select the timesheet2 (which will be without data all the time)" and copy it into my table (which will be empty)
I'm not sure it's the right method, but I think it's feasible and it would solve the problem
Code:
Sub StartExtract()
' Set the sid and client to connect to
W_System = "P10320"
' Run the GUI script
RunGUIScript
' End the GUI session
objSess.EndTransaction
'effacer contenu feuille temp
Sheets("temp").Select
Cells.Select
Selection.Delete Shift:=xlUp
' Switch to the worksheet where the data is loaded to
Sheets("temp").Select
' Load the CSV file
OpenCSVFile
Sheets("BGSOCIAL").Select
Columns("B:G").Select
Selection.ClearContents
Sheets("temp").Range("B:G").Copy
Sheets("BGSOCIAL").Range("B:G").PasteSpecial Paste:=xlPasteValues
Sheets("BGSOCIAL").Select