View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Ed White Ed White is offline
external usenet poster
 
Posts: 34
Default VSTO BeforeDoubleClick edit mode

That worked...thanks.
Also, knowing that VSTO does not always show expections is very helpful.
Regards,
Ed


""Ji Zhou [MSFT]"" wrote:

Hello Ed White,

Thanks for your detailed information! I can reproduce the problem with the
codes you provide. From test on my side, I find that the problem is caused
by an unhandled exception, rather than the edit mode we talked above.

To select a cell in another sheet by codes, firstly we need to call the
Sheet.Activate() method to activate the target sheet, and then call the
Range.Select() method to select that cell. Otherwise an exception will be
thrown with error message "The Select method of Range class failed". Codes
below that line will not get executed.

The following codes have already worked on my side:

Private Sub Sheet5_BeforeDoubleClick(ByVal Target As
Microsoft.Office.Interop.Excel.Range, ByRef Cancel As System.Boolean)
Handles Me.BeforeDoubleClick
Stop
Try
Globals.Sheet8.Range("Ticker").Value = Target.Value
Globals.Sheet8.Activate()
Globals.Sheet8.Range("Ticker").Select()
MsgBox("Got here to Sheet5")
Globals.Sheet8.EvaluateTkr()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub

Friend Sub EvaluateTkr()
Try
Me.Activate()
Me.Range("Ticker").Select()
MsgBox("Got here to Sheet8")
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub

If we comment the two lines of Globals.Sheet8.Activate() and Me.Activate(),
and then debug it in Visual Studio, we can find the code flow will enter
into the Catch block. In VSTO projects, the unhandled exceptions may be
swallowed silently by Office application. So, I suggest you always put the
codes in a Try/Catch block like above codes did. Please let me know if you
have any future questions on this.


Best regards,
Ji Zhou , remove €˜online.)
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.