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.
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.
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.
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).
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With