3

I am delivering external data using the dispatch interface via a COM dll to an Excel plugin. In the VBA sink method, I check that Application.Ready = True before trying to write the data to the appropriate cell like this,

            If Application.Ready = True Then
                With Workbooks(bookName).Sheets(sheetName).Range(rangeName)
                    .Value = thisData
                End With
            Else
                Debug.Print "Dropped Payload"
            End If

I don't want to just drop the data, so I've tried to do a few things to get it right.

  • Call Application.OnTime instead of setting the value. Unfortunately, Excel would not let me call Application.OnTime when Application.Ready=False.
  • Use the technique here to start a Windows timer that then calls OnTime. The problem here was that multiple events were coming in on top of each other and they were all trying to access the AfterUDFRoutine1 simultaneously, causing a crash.

So my latest thought is to put the data into a queue and then drain the queue when Application.Ready=True. To implement this, I need an event to fire when Application.Ready changes state, but I can't find the event in the list. Does anybody know if this exists and how to expose it? Alternatively, if somebody has a better idea of how to make this work I'm very open to it. The only suggestion I can't do is to use RTD instead of the dispatch I have already - I can't change that part.

feetwet
  • 3,248
  • 7
  • 46
  • 84
Dan
  • 31
  • 2

0 Answers0