My VBA code in Access is trying to write cmd lines in and run a batch file, which executes some R lines to create a txt file, before a webbrowser control on an Access form updates its ControlSource wth this newly created txt file.
dim FileNumber as int
dim isDone as variant
' write in and create a batch file
FileNumber = FreeFile
Print #FileNumber, "cmd to run R lines..."
Close #FileNumber
'run batch file
isDone = Shell("D:\path\BatchFile.bat", vbNormalFocus)
'update webbrowser control source
Me.WebB63.ControlSource = "=""D:\path\TextFile.txt"""
The problem is my VBA codes continues to run before the cmd lines in the batch file are fully executed. So the webbrowser is already looking for the txt file before it is actually created and gives this error becuase it couldn't find the txt file.
How can I code so the the batch file is fully executed and txt is created before updating webbrowser control source?
Thanks