Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to get the text and cursor position from the formula bar in Excel?

I'd like to get the current (possibly uncommitted) text out of the formula bar in Excel (from an addin in-process). All "usual" techniques don't work, like GetWindowText(...), etc.

As for cursor position: GetCaretPos actually works (returns the x,y coords of the caret), but EM_CHARFROMPOS doesn't (always returns 0) so that's a dead end.

Is this functionality exposed through COM or to the XLL API in any way?

EDIT: I'd also like to point out that I think the majority of my issues come from the fact that the formula bar is (at least I'm 99% sure) NOT an edit control, which can be seen by looking at its window class.

like image 461
Steve Avatar asked Feb 26 '11 01:02

Steve


People also ask

How do you show the cursor in the formula bar in Excel?

If you want the cursor to move to the formula bar, see below. Once you are editing a cell, you can use the F2 / Ctrl+U again to toggle through available edit modes (edit, enter, point). "Point" and "Enter" work similarly and allow you to point to a cell. "Edit" mode simply moves the cursor in the formula text.

How do I show the formula bar and name box in Excel?

Unhide formula bar via Excel OptionsClick File (or the Office button in earlier Excel versions). Go to Options. Click Advanced in the left pane. Scroll down to the Display section and select the Show Formula bar option.

How do I move the cursor to the top of a cell in Excel?

By default, the parameter for moving the cursor in Excel after pressing the "Enter" key is directed to the bottom, to the bottom cell (and if you press SHIFT+ENTER, the cursor will go to the top cell).

How do you enter text in the formula bar?

Entering And Editing Data In The Formula BarSelect the cell where you want to enter your data and start typing. As you type the data notice the data also appear in the Formula Bar. To accept the data either click the Check Mark or press Enter. To discard the data either click the X or press Esc.


1 Answers

The formula bar, and indeed most of the controls in Office are non-standard. Sending standard messages will not yield success.

I imagine the only option will be to reverse-engineer the executable code.

like image 187
David Heffernan Avatar answered Sep 28 '22 18:09

David Heffernan