开发者

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

开发者 https://www.devze.com 2023-02-13 07:44 出处:网络
I\'d like to get the current (possibly unco开发者_运维技巧mmitted) text out of the formula bar in Excel (from an addin in-process).All \"usual\" techniques don\'t work, like GetWindowText(...), etc.

I'd like to get the current (possibly unco开发者_运维技巧mmitted) 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.


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.


SteveN, which version of Excel ? The control will be a window. Office 2010 is 'nicer' in this respect, using more standard controls. You could use Spy to watch all the messages that get sent to that control and try mimicking those to see what you get. Long road though.

0

精彩评论

暂无评论...
验证码 换一张
取 消