Hi,
I have a macro that opens and modifies a lot of different files. Currently the only way I can make this work is by using a lot of Application.OnTime commands, which is making the code extremely unwieldly.
for some background, the reason I do this is as follows (simplified):

I Start with a template that I input data on, then execute the Macro.
The code goes like this
Sub 1
call download File from SAP
call Modify downloaded file
End Sub
If I try to run the code like that however, it gets an error when trying to modify the downloaded file, because it doesn't recognize that the file has been opened, a subscript out of range error. (if i run through line by line the code works because the system processes that the file has been opened)
so what I ended up doing is this:
Sub download File from SAP
'download File from SAP code
...
...
...
Application.OnTime (Now + TimeValue("0:00:2")), "Modify downloaded file"
end sub

sub Modify downloaded file
Modify downloaded file code
...
...
...
end sub
This works, but is making it very hard to keep track of everything since it cant all be called in one sub.

My googling makes it seem like I should be able to do what follows, but it doesn't work.
Am I misinterpreting what DoEvents does / is there any alternative to get something like this?

Sub 1
call download File from SAP
DoEvents
call Modify downloaded file
End Sub
Any advice is much appreciated.