Microsoft.Office.Interop.Excel: Method 'Cells' not found
Posted: Tue Apr 19, 2016 11:08 am
Hello,
following code works well for me in Ms Visual Studio Express but unfortunately not in Ranorex.
In Ranorex, I receive following error:
'object' does not contain a definition for 'Cells' and no extension method 'Cells' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?) (CS1061) - D:\ranorexTutorial\lab\lab\excInt.cs:55,59
I use identical Microsoft.Office.Interop.Excel dll file as source.
Here, see snapShots from Ms Visual Studio and from Ranorex when trying to run the code:
Ms Visual Studio (without error): Ranorex (with error): Thank you!
following code works well for me in Ms Visual Studio Express but unfortunately not in Ranorex.
Code: Select all
/*
* Created by Ranorex
* User: Drake
* Date: 4/19/2016
* Time: 6:00 AM
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Drawing;
using System.Threading;
using WinForms = System.Windows.Forms;
using Ranorex;
using Ranorex.Core;
using Ranorex.Core.Testing;
using Microsoft.Office.Interop.Excel;
namespace lab
{
/// <summary>
/// Description of ExcInt.
/// </summary>
[TestModule("418266C8-4FB9-4B06-A823-044A2DFEFBDF", ModuleType.UserCode, 1)]
public class ExcInt : ITestModule
{
/// <summary>
/// Constructs a new instance.
/// </summary>
public ExcInt()
{
// Do not delete - a parameterless constructor is required!
}
/// <summary>
/// Performs the playback of actions in this module.
/// </summary>
/// <remarks>You should not call this method directly, instead pass the module
/// instance to the <see cref="TestModuleRunner.Run(ITestModule)"/> method
/// that will in turn invoke this method.</remarks>
void ITestModule.Run()
{
Mouse.DefaultMoveTime = 300;
Keyboard.DefaultKeyPressTime = 100;
Delay.SpeedFactor = 1.0;
String dtPath = "d:\\ranorexTutorial\\dtLab.xlsx";
String dtSheet = "labSheet01";
Microsoft.Office.Interop.Excel.Application objExcel = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook objBook = objExcel.Workbooks.Open(dtPath);
var objSheet = objBook.Worksheets[dtSheet];
System.Windows.Forms.MessageBox.Show(objSheet.Cells(2, 2).Text);
}
}
}
'object' does not contain a definition for 'Cells' and no extension method 'Cells' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?) (CS1061) - D:\ranorexTutorial\lab\lab\excInt.cs:55,59
I use identical Microsoft.Office.Interop.Excel dll file as source.
Here, see snapShots from Ms Visual Studio and from Ranorex when trying to run the code:
Ms Visual Studio (without error): Ranorex (with error): Thank you!