I use the below code to paste into a browser tab in Chrome, which will then open into a CSV file. This works fine when I F8 through the code, but when I run the code, the file is slow to open and the code just runs through. My question - is there a ReadyState4 equivalent for Chrome, where I can delay the code until the new CSV file opens? Any other advice/options on how to do this would be appreciated. Have attached a workbook as well.
Sub Import_Data()
Application.DisplayAlerts = False
Dim Count, FileSaveFolder As Long
Dim DogName, FormDownloadURL, FileSavePath, FName As String
Count = 2
FileSaveFolder = Sheet1.Cells(2, 3)
FileSavePath = Sheet1.Cells(3, 3)
DogName = Sheet2.Cells(Count, 1)
FormDownloadURL = Sheet2.Cells(Count, 4)
FName = ThisWorkbook.Name
Do While DogName <> ""
Shell ("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe -url " & FormDownloadURL)
Do While ActiveWindow.Caption = "FormDownloader.xlsm"
Loop
Closefile = ActiveWindow.Caption
LastRow = Cells(Rows.Count, 1).End(xlUp).Row + 1
Cells(1, 18).Value = "DogName"
Cells(2, 18).Value = DogName
Range(Cells(2, 18), Cells(LastRow - 1, 18)).Select
Selection.FillDown
ActiveWorkbook.SaveAs Filename:=FileSavePath & FileSaveFolder & "\" & DogName & ".csv"
ActiveWindow.Close
Windows(FName).Activate
Sheet2.Select
Count = Count + 1
DogName = Sheet2.Cells(Count, 1)
FormDownloadURL = Sheet2.Cells(Count, 4)
Loop
End Sub
Bookmarks