I have a simple visual basic program that adds a blank comment to a cell and then should open the comment for editing. It adds the blank comment correctly, but it opens the comment only about half the time (more or less randomly). I think the problem is that sometimes - but not always! - the Active Cell loses focus so it doesn't receive the SendKeys output. Is there a way to insure that the Active Cell stays active?
Code:
Sub AddBlankComment()
ActiveCell.AddComment ("") ' Adds blank comment
SendKeys "+{F2}", True ' Excel shortcut (shift-F2) to open comment for editing
' (True causes program to wait for action to complete.)
End Sub