Below is my code so far. It goes to a url, logs in, runs a search, downloads the results, and then the "Sendkeys" line at the very end hits enter and opens the file from the Internet explorer download prompt that asks whether I want to open or save the file. What I want to do is, when the report opens in excel, copy the data from the newly opened file into the file that the macro was run from. I've tried to add this:
where the M&A report generator file is the original workbook containing the macro, but I get "runtime error 9, subscript out of range". It seems to be executing the copy/paste before the new workbook opens. I've tried to put an application.wait in there too, but the same thing happens. It seems the workbook won't open until the entirety of my code finishes running. Can anyone offer any suggestions to make this work?
On a side note, in a previous iteration of the code I had all the
replaced with
but with it set up that way, I sometimes got errors when I would run it, and other times no errors. Anyone have any idea why?
I'd prefer to have the do while mybrowser.ready state<>4 piece than the wait because it seems that it should be more reliable. Maybe I am not using it properly.
Bookmarks