active celle i excel ved brug af System.Runtime.InteropServices;
Jeg vil gerne have den aktive celle i Excel ved brug af System.Runtime.InteropServices.Jeg har nedenstående kode, hvor jeg har aktive workbook og aktive sheet.
Mangler bare aktive celle.
Men hvordan ?
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using Excel = Microsoft.Office.Interop.Excel;
namespace Excel_TEST
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
//Gets Excel and gets Activeworkbook and worksheet
Excel.Application oXL;
Excel.Workbook oWB;
Excel.Worksheet oSheet;
oXL = (Excel.Application)Marshal.GetActiveObject("Excel.Application");
oXL.Visible = true;
oWB = (Excel.Workbook)oXL.ActiveWorkbook;
oSheet = oWB.ActiveSheet;
}
}
}