M
Michal
Hi,
I have followed this walktrough
http://msdn.microsoft.com/en-us/library/bb608614.aspx on MSDN that describes
how to call managed code from VBA.
All seems to be working fine ( when i execute CallVSTOMethod from vithin VBA
editor i will get "This is my data" in the first cell on the worksheet).
The problem comes when i try to call the function as a UDF. I will go to the
cell and write
=CallVSTOMethod()
Expecting to get the "This is my data" in the first cell. Insted of that i
will get an error "<Exception from HRESULT: 0x800A03EC>" on the
automation.ImportData line in the CallVSTOMethod VBA method.
When i debug the ImportData c# function i discovered that the exception
occurs at the
range1.Value2 = "This is my data"; line, particulary when trying to access
Value2 of range1 object.
The exception thrown there is :
range1.Value2 Cannot obtain fields or call methods on the instance
of type 'Microsoft.Office.Interop.Excel.Range' because it is a proxy to a
remote object.
Onece again if i execute the same code from VBA (by hitting F5 while cursur
is in the function) it works fine with no error.
Any ideas?
Thanx
PS: Im running VS 2008 and Excel 2007
I have followed this walktrough
http://msdn.microsoft.com/en-us/library/bb608614.aspx on MSDN that describes
how to call managed code from VBA.
All seems to be working fine ( when i execute CallVSTOMethod from vithin VBA
editor i will get "This is my data" in the first cell on the worksheet).
The problem comes when i try to call the function as a UDF. I will go to the
cell and write
=CallVSTOMethod()
Expecting to get the "This is my data" in the first cell. Insted of that i
will get an error "<Exception from HRESULT: 0x800A03EC>" on the
automation.ImportData line in the CallVSTOMethod VBA method.
When i debug the ImportData c# function i discovered that the exception
occurs at the
range1.Value2 = "This is my data"; line, particulary when trying to access
Value2 of range1 object.
The exception thrown there is :
range1.Value2 Cannot obtain fields or call methods on the instance
of type 'Microsoft.Office.Interop.Excel.Range' because it is a proxy to a
remote object.
Onece again if i execute the same code from VBA (by hitting F5 while cursur
is in the function) it works fine with no error.
Any ideas?
Thanx
PS: Im running VS 2008 and Excel 2007