How do you get an Excel Range in a TextBox?

  • Thread starter Thread starter pinkfloydfan
  • Start date Start date
P

pinkfloydfan

Hi again

My C# Form is part of a .xll . I have managed to get the Form to open
up but now what I want to do for one of the TextBoxes is have the user
input an Excel range which can set by clicking a cell/range back in
the calling session of Excel.

So, if the user clicked on cell $A$1 then the TextBox would show the
address of that cell.

Does anybody have any idea how to do this please?

Thanks a lot
Lloyd

p.s. I am using ExcelDna to make my code visible to Excel.
 
Lloyd,

The only way I can think of doing this would be to set up an event
handler for the workbook/worksheets to see if the selection changes once
your form is opened (you should be able to get it through the application
instance that is passed to your form, or made available to you through some
other mechanism).

When your event fires, you update the text in the textbox.
 
Thanks Nicholas

Having reviewed my project and your comments I now realise that I need
to have a handle to the calling application instance (otherwise I'll
never be able to paste the results back there)...I did try the Parent
property of the Form but that returned null so now I haven't got a
clue how you find that out.

Can you please tell me?

Thanks a lot
Lloyd
 
Lloyd,

You are going to have to have the caller that exposes the form pass the
reference somehow to your form.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top