Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Determine current Excel cursor position using VB .NET

Status
Not open for further replies.

KLK000

MIS
May 22, 2002
37
US
Using VB .NET, I need to determine which cell the user is currently positioned on in a spreadsheet the user has opened in Excel and then I need to retrieve the cell formula. I've tried using:

Public oExcel As Excel.Application
Public oBook As Excel.Workbook

oExcel = New Excel.Application
oBook = oExcel.Workbooks.Open([path to spreadsheet])
sFormula = oExcel.ActiveCell.Cells.Formula

However, this retrieves the cell formula that the user was last positioned on when he closed the spreadsheet. I need to get the cell he is currently positioned on.

Thanks for any and all help.

Ken
 
I still haven't found a way to do this. I've searched various sites but can't find an answer. There has to be a way to do this.
 
In the code above, aren't you creating a new instance of the workbook and not the version the user opened on their own?

I would think you need to plant some vba code in the spreadsheet to get the information you need.

Scott
Programmer Analyst
<{{><
 
You're correct, I am creating a new instance of the workbook and that's why I can't get the information I want. Is there a way to get the instance of the currently opened excel workbook? The vba code in the spreadsheet calls my vb .net application.
 
what is the purpose of this app? Is the purpose to create/modify Excel formulas?

You could pass the formula to the vb app by command line
or create an add-in for Excel that accomplishes the functionality in your stand alone app.

Scott
Programmer Analyst
<{{><
 
The purpose is to provide an enhanced proofing capability of existing formulas.

I thought about passing the formula using the command line argument but this won't give me the full functionality I would like.

I currently have a vba add-in but as you know the form support is limited. With all the richness of VB .NET, I could provide a really nice interface... provided I can get the correct instance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top