View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default VSTO and Excel--End Cell Edit Mode?

That sounds kind of dangerous to me.

I sometimes type something in the cell, then realize that it's wrong before I
hit enter. So I hit escape to leave the cell as-is (as-was?).

If I'm typing a formula, the enter key could just yell at me that my formula
isn't correct.

And if I'm evaluating a part of the formula (select and hit F9), then that
Sendkeys may have just screwed up my real formula.

I can't offer anything better. But sometimes warnings are good <bg.

"Peter Huang [MSFT]" wrote:

Hi

Based on my research, I think you may try to use the SendKeys approach to
send the Enter keyboard key to the active cell, just as we do manually.

Private Sub ThisWorkbook_Open() Handles ThisWorkbook.Open
cb = ThisApplication.CommandBars.Add("Test", , False, True)
cbb = cb.Controls.Add(Office.MsoControlType.msoControlBu tton, , , ,
True)
cbb.Caption = "Hello:"
cbb.Tag = "1:"
cbb.FaceId = 17
End Sub

Private Sub ThisWorkbook_BeforeClose(ByRef Cancel As Boolean) Handles
ThisWorkbook.BeforeClose
Cancel = False
cbb.Delete(True)
cb.Delete()
End Sub

Private Sub cbb_Click(ByVal Ctrl As
Microsoft.Office.Core.CommandBarButton, ByRef CancelDefault As Boolean)
Handles cbb.Click
SendKeys.Send("{ENTER}")
End Sub

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.


--

Dave Peterson