I am using office 2007 excel work sheet function in c# code. VS2010 issues this warning
Warning 3 Ambiguity between method 'Microsoft.Office.Interop.Excel._Worksheet.Activate()' and non-method 'Microsoft.Office.Interop.Excel.DocEvents_Event.Activate'. Using method group. D:\EXLANEDB01p\dev\libraries\EXCEL\Excel.cs 531 95 EXCEL
How do I resolve this ? the call is
xSheet.Activate();
where xSheet
passed as ref in the call as
ref Microsoft.Office.Interop.Excel.Worksheet xSheet
You need to disambiguate the Activate
name. Within the Worksheet interface, Activate
is either a method (if looked at as a _Worksheet
object) or an event (if looked at as a DocEvents_Event
object).
Cast your object to Microsoft.Office.Interop.Excel._Worksheet
first then call Activate()
.
((Microsoft.Office.Interop.Excel._Worksheet)xSheet).Activate();
Or declare a new _Worksheet
variable and use that within your method.
_Worksheet sheet = xSheet;
sheet.Activate();
Otherwise you could change your method declaration to take a reference to a _Worksheet
instead of a Worksheet
as well as all associated declarations.
void MyMethod(ref Microsoft.Office.Interop.Excel._Worksheet xSheet)
{
// ...
}
// usage:
_Worksheet sheet = new Worksheet();
MyMethod(ref sheet);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With