I am currently develping an Excel Add-in, and have a quick question. I have a form that I need to allow the user to enter a range of cells in. I have added a button next to the range textbox with the intention of allowing the user to click the button, go to the spreadsheet and select the range, then return the range to the textbox. My question is how do I access the current open file? I know htat I can use
Excel.Application oXL; oXL = new Excel.Application();
To start Excel, then use similar functions to create a new workbook, etc... but how do I get my Excel.Application object pointed to the current open Excel app, and then point my Excel._Workbook object pointed to the current workbook and the sheet object the same?
Thanks in advance,
Ed.
Current Code is:
public partial class UI_SteamPropForm : Form
{
public UI_SteamPropForm()
{
InitializeComponent();
}
private void UI_SteamPropForm_Load(object sender, EventArgs e)
{
ui_PressureCheckBox.Checked = true;
ui_TempCheckBox.Checked = false;
}
private void ui_PressureCheckBox_CheckedChanged(object sender, EventArgs e)
{
if (ui_PressureCheckBox.Checked)
ui_TempCheckBox.Checked = false;
}
private void ui_TempCheckBox_CheckedChanged(object sender, EventArgs e)
{
if (ui_TempCheckBox.Checked)
ui_PressureCheckBox.Checked = false;
}
private void ui_CancelButton_Click(object sender, EventArgs e)
{
this.Close();
}
private void ui_SelectCellsButton1_Click(object sender, EventArgs e)
{
Excel.Application oXL;
Excel._Workbook oWB;
Excel._Worksheet oSheet;
Excel.Range oRng;
}
}
notice that this is a form called when someone hits a button on the ribbon menu, and thus is not in the ThisAddIn.cs file.

New Topic/Question
Reply



MultiQuote



|