I have a simple piece of VBA that is triggering a large OPL optimisation through VBA -> COM wrapper -> .NET -> OPL and I want to provide the user with more granular status information than that provided by checkpointing the stages of New OplFactory, Factory.CreateOplProject, Project.MakeRunConfiguration, RunConfiguration.getOplModel(), Model.Generate, Model.Cplex.solve() and Model.PostProcess. The optimisation takes upwards of 10 minutes and so some reassurance to the user that all is well is needed, particularly during Cplex.solve. I'm trying to get the engine log and other logs passed back to the user in real time but I'm struggling to make this happen. Obviously all of this information is available through the IDE, but they need to run it from the VBA.
My approaches and their issues have been:
Use .setOut and create a TextWriter event handler in VBA to writethe log to a textbox
- Lack of easy multithreading in VBA makes this near impossible, I think
Write the log to a text file and then use "Get-Content <logfile> -Wait" in PowerShell to perform a "tail -f" on the text file
- I know this is somewhat crude, but it's probably good enough
- I can't see how to write the log to a text file as .setOut won't directly write to a file and my attempts to use Scripting.FileSystemObject and Scripting.TextStream with a Cplex.setOut in the VBA didn't work
I've read other posts on this subject in this forum, but none have helped resolve this issue.
I have a feeling I'm missing someting obvious here so any suggestions as to how to make either of the above approaches work, or else suggesting a completely different approach would be much appreciated.