Murray Brown
asked on
VB.net Range selection requires user hitting enter
Hi
In VB.net 2010 I am using the following code to allow the user to select an Excel range from behind an Excel form. The problem is that omnce the range is selected the user still has to hit enter for the form to come back up. I am pretty sure that this wasn't the case in previous versions. How do I change it so that once the range is selected the rest of the code runs automatically?
Thanks
In VB.net 2010 I am using the following code to allow the user to select an Excel range from behind an Excel form. The problem is that omnce the range is selected the user still has to hit enter for the form to come back up. I am pretty sure that this wasn't the case in previous versions. How do I change it so that once the range is selected the rest of the code runs automatically?
Thanks
Private Sub Button_SelectRange_Click(sender As System.Object, e As System.EventArgs) Handles Button_SelectRange.Click
' MsgBox(Globals.ThisAddIn.Application.ActiveSheet.cells(1, 1).value)
Try
Me.Hide()
Dim R As Microsoft.Office.Interop.Excel.Range
Dim A As String
'note how the Application.InputBox brings up different settings to just InputBox
R = Globals.ThisAddIn.Application.InputBox(Prompt:="Please select range", Type:=8)
A = R.Address
Me.TextBox1.Text = A
Me.Show()
Me.TopMost = True
Exit Sub
Catch
MsgBox("Please select a valid range!")
Me.Show()
End Try
End Sub
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER