I have created a very simple modal form with two buttons: one just closes the form, and the other calls Application.RTD.RefreshData
. In Excel 2003 this all works just fine, but in Excel 2010 the Application.RTD.RefreshData
crashes with
Run-time error '1004': Application-defined or object-defined error
If I create the form as modeless everything works fine in both Excel 2003 and Excel 2010.
For what it's worth, this is all the code behind the form:
Private Sub RefreshDataButton_Click()
Application.RTD.RefreshData
End Sub
Private Sub CloseButton_Click()
Call Unload(Me)
End Sub
And I invoke the form using this code in my sheet:
Private Sub CommandButton1_Click()
Dim form As UserForm1
Set form = New UserForm1
form.Show vbModal
End Sub
I've scoured Google and SO for any information on this to no avail. Is it a known issue with Excel 2010, or am I really not allowed to call Application.RTD.RefreshData
from a modal form?
EDIT: I should add that as far as I can tell there are no RTD servers in my Excel session.
EDIT2: Further investigation: the error does not occur in Excel 2003 or 2007; it does occur in 2010 and 2013.