API: Excel and Prime. VBA timing issues?
Hi,
Following my previous thread, I can successfully pass data from Excel to Mathcad, calculate, and then take the outputs back to Excel. Thank you
This is a summary of the code I am using.
- Get inputs, Aliases, units from Excel.
- Open Prime and worksheet.
- Get Prime Input Aliases.
- Loop through each Prime Input Alias and match them with Excel Aliases. If there is a match, add the corresponding value and units to Prime.
- Calculate
- Obtain Prime output as a matrix.
- Loop through each Output element, store its value and send the element back to Excel.
This is the weird part that I can't figure it out.
If the program runs by clicking the ActiveX Command Button, the Outputs are not added to the Excel.
If the program runs in VBA and there are break stops, the program adds the Outputs to Excel as intended.
The minimum number of break stops seems to be two. One after the I get the Outputs and one after the loops that moves the Output data back to Excel.
This issue indicates that there is a timing issue between VBA and Prime. This is what I have tried:
1.- Increase DefaultCalculationTimeout to 600 seconds
2.- Add Application.Wait(Now + TimeValue("0:00:30") after each break stop.
3.- Add Application.Wait(Now + TimeValue("0:00:2") inside each loop to slowly pass the data.
Unfortunately, none of that seems to work. Any ideas on how to tackle this issue?
Regards,

