I am currently trying to implement a button that simply refreshes the data in my workbook and then exports a specific sheet as a PDF. Everything works fine except that the refresh does not finish until after the PDF is created. The link below seemed to be an answer but it still does not work:
works properly for refreshing the workbook but it starts, gets interrupted by my code to export as a PDF, and then finishes. The article I linked states that
should be used if I wanted synchronous behaviour and for the refresh to finish before anything else occurs. However, when I use the button with this line, nothing happens. I thought maybe it was my version and that mine does not allow for the second type of refreshing but I am not sure how I can check.
Any help would be appreciated.
I have to disagree with the answer by @Zhenya Kovalyov. EikonRefreshWorkbook macro is specifically designed to refresh all =TR functions in a workbook synchronously. The call NumFuncRefreshed = Application.Run("EikonRefreshWorkbook") returns the number of functions that have been refreshed when the call returns due to the job finished or due to timeout.
@jingwersen, it would be very helpful if you shared an example spreadsheet where running Application.Run("EikonRefreshWorkbook") has no effect. Or at least share an example of worksheet function that doesn't get refreshed. Note that running EikonRefreshWorkbook macro has no effect on =TF functions.
EikonRefreshWorkbook macro is available in Eikon version 4.0.23 and higher. You can check the Product Version in Help - About available in Thomson Reuters ribbon, though I don't believe the version of Eikon is the issue here. If EikonRefreshWorkbook macro were not available on your machine I would expect Application.Run("EikonRefreshWorkbook") to produce VBA runtime error 1004: Cannot run macro 'EikonRefreshWorkbook'...
@jingwersen in my opinion, what you are trying to do is asynchronous by nature, so it is quite difficult to propose anything without looking at the file. But you can explore either of these:
I would go for 2 or 3, let me know if you require any further info.