![]() |
Keep Object with Focus on Display Screen
I have a page with many objects (textboxes, Option
buttons, comboboxes). There are more objects than can fit on the display screen. I have used the code below to tab, shift/tab back and forth between objects on the page Does anyone know how to code to accomplish the following: When a field which I have progressivly tabbed into, is beyond the display screens view (below), I would like the screen to shift down the page so that the object which I have tabbed into, which has the focus (e.g. textbox1.activate) is in my view without me having to scroll down, or do any extra keystrokes. Private Sub cboEnergyType_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) Select Case KeyCode Case vbKeyTab, vbKeyReturn, vbKeyDown, vbKeyUp Application.ScreenUpdating = False bBackwards = CBool(Shift And 1) Or (KeyCode = vbKeyUp) If Application.Version < 9 Then Sheet1.Range ("A1").Select If bBackwards Then With Me.txtStopPayComments .Activate .SelStart = 0 .SelLength = Len(.Text) End With Else With Me.txtAcctNo .Activate .SelStart = 0 .SelLength = Len(.Text) End With End If Application.ScreenUpdating = True End Select End Sub Thank you in advance God bless you |
Keep Object with Focus on Display Screen
Untested, but try something like the below modifications.
Private Sub cboEnergyType_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) Dim rng as Range Select Case KeyCode Case vbKeyTab, vbKeyReturn, vbKeyDown, vbKeyUp Application.ScreenUpdating = False bBackwards = CBool(Shift And 1) Or (KeyCode = vbKeyUp) If Application.Version < 9 Then Sheet1.Range ("A1").Select If bBackwards Then set rng = Me.txtStopPayComments.TopLeftCell if Intersect(activeWindow.VisibleRange,rng) is nothing then ActiveWindow.ScrollRow = rng.row ActiveWindow.ScrollColumn = rng.column End if With Me.txtStopPayComments .Activate .SelStart = 0 .SelLength = Len(.Text) End With Else set rng = Me.txtAcctNo.TopLeftCell if Intersect(activeWindow.VisibleRange,rng) is nothing then ActiveWindow.ScrollRow = rng.row ActiveWindow.ScrollColumn = rng.column End if With Me.txtAcctNo .Activate .SelStart = 0 .SelLength = Len(.Text) End With End If Application.ScreenUpdating = True End Select End Sub -- Regards, Tom Ogilvy "andy" wrote in message ... I have a page with many objects (textboxes, Option buttons, comboboxes). There are more objects than can fit on the display screen. I have used the code below to tab, shift/tab back and forth between objects on the page Does anyone know how to code to accomplish the following: When a field which I have progressivly tabbed into, is beyond the display screens view (below), I would like the screen to shift down the page so that the object which I have tabbed into, which has the focus (e.g. textbox1.activate) is in my view without me having to scroll down, or do any extra keystrokes. Private Sub cboEnergyType_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) Select Case KeyCode Case vbKeyTab, vbKeyReturn, vbKeyDown, vbKeyUp Application.ScreenUpdating = False bBackwards = CBool(Shift And 1) Or (KeyCode = vbKeyUp) If Application.Version < 9 Then Sheet1.Range ("A1").Select If bBackwards Then With Me.txtStopPayComments .Activate .SelStart = 0 .SelLength = Len(.Text) End With Else With Me.txtAcctNo .Activate .SelStart = 0 .SelLength = Len(.Text) End With End If Application.ScreenUpdating = True End Select End Sub Thank you in advance God bless you |
Keep Object with Focus on Display Screen
Thank you Tom for your reply,
The modified code does do the screen movement I had requested. However when the screen reacts to the forward/backward movement adjusting itself to keep the object on the display screen, it puts the object in the upper left corner of the display and I can't see any of the labels to the left. None of the objects are left alligned. The code works, however can I just send the screen position to the leftmost cell of the row the object is sitting on? Thank you again for you help God bless you -----Original Message----- Untested, but try something like the below modifications. Private Sub cboEnergyType_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) Dim rng as Range Select Case KeyCode Case vbKeyTab, vbKeyReturn, vbKeyDown, vbKeyUp Application.ScreenUpdating = False bBackwards = CBool(Shift And 1) Or (KeyCode = vbKeyUp) If Application.Version < 9 Then Sheet1.Range ("A1").Select If bBackwards Then set rng = Me.txtStopPayComments.TopLeftCell if Intersect (activeWindow.VisibleRange,rng) is nothing then ActiveWindow.ScrollRow = rng.row ActiveWindow.ScrollColumn = rng.column End if With Me.txtStopPayComments .Activate .SelStart = 0 .SelLength = Len(.Text) End With Else set rng = Me.txtAcctNo.TopLeftCell if Intersect (activeWindow.VisibleRange,rng) is nothing then ActiveWindow.ScrollRow = rng.row ActiveWindow.ScrollColumn = rng.column End if With Me.txtAcctNo .Activate .SelStart = 0 .SelLength = Len(.Text) End With End If Application.ScreenUpdating = True End Select End Sub -- Regards, Tom Ogilvy "andy" wrote in message ... I have a page with many objects (textboxes, Option buttons, comboboxes). There are more objects than can fit on the display screen. I have used the code below to tab, shift/tab back and forth between objects on the page Does anyone know how to code to accomplish the following: When a field which I have progressivly tabbed into, is beyond the display screens view (below), I would like the screen to shift down the page so that the object which I have tabbed into, which has the focus (e.g. textbox1.activate) is in my view without me having to scroll down, or do any extra keystrokes. Private Sub cboEnergyType_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) Select Case KeyCode Case vbKeyTab, vbKeyReturn, vbKeyDown, vbKeyUp Application.ScreenUpdating = False bBackwards = CBool(Shift And 1) Or (KeyCode = vbKeyUp) If Application.Version < 9 Then Sheet1.Range ("A1").Select If bBackwards Then With Me.txtStopPayComments .Activate .SelStart = 0 .SelLength = Len(.Text) End With Else With Me.txtAcctNo .Activate .SelStart = 0 .SelLength = Len(.Text) End With End If Application.ScreenUpdating = True End Select End Sub Thank you in advance God bless you . |
Keep Object with Focus on Display Screen
sure, just set ScrollColumn to 1
ActiveWindow.ScrollColumn = 1 Regards, Tom Ogilvy "andy" wrote in message ... Thank you Tom for your reply, The modified code does do the screen movement I had requested. However when the screen reacts to the forward/backward movement adjusting itself to keep the object on the display screen, it puts the object in the upper left corner of the display and I can't see any of the labels to the left. None of the objects are left alligned. The code works, however can I just send the screen position to the leftmost cell of the row the object is sitting on? Thank you again for you help God bless you -----Original Message----- Untested, but try something like the below modifications. Private Sub cboEnergyType_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) Dim rng as Range Select Case KeyCode Case vbKeyTab, vbKeyReturn, vbKeyDown, vbKeyUp Application.ScreenUpdating = False bBackwards = CBool(Shift And 1) Or (KeyCode = vbKeyUp) If Application.Version < 9 Then Sheet1.Range ("A1").Select If bBackwards Then set rng = Me.txtStopPayComments.TopLeftCell if Intersect (activeWindow.VisibleRange,rng) is nothing then ActiveWindow.ScrollRow = rng.row ActiveWindow.ScrollColumn = rng.column End if With Me.txtStopPayComments .Activate .SelStart = 0 .SelLength = Len(.Text) End With Else set rng = Me.txtAcctNo.TopLeftCell if Intersect (activeWindow.VisibleRange,rng) is nothing then ActiveWindow.ScrollRow = rng.row ActiveWindow.ScrollColumn = rng.column End if With Me.txtAcctNo .Activate .SelStart = 0 .SelLength = Len(.Text) End With End If Application.ScreenUpdating = True End Select End Sub -- Regards, Tom Ogilvy "andy" wrote in message ... I have a page with many objects (textboxes, Option buttons, comboboxes). There are more objects than can fit on the display screen. I have used the code below to tab, shift/tab back and forth between objects on the page Does anyone know how to code to accomplish the following: When a field which I have progressivly tabbed into, is beyond the display screens view (below), I would like the screen to shift down the page so that the object which I have tabbed into, which has the focus (e.g. textbox1.activate) is in my view without me having to scroll down, or do any extra keystrokes. Private Sub cboEnergyType_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) Select Case KeyCode Case vbKeyTab, vbKeyReturn, vbKeyDown, vbKeyUp Application.ScreenUpdating = False bBackwards = CBool(Shift And 1) Or (KeyCode = vbKeyUp) If Application.Version < 9 Then Sheet1.Range ("A1").Select If bBackwards Then With Me.txtStopPayComments .Activate .SelStart = 0 .SelLength = Len(.Text) End With Else With Me.txtAcctNo .Activate .SelStart = 0 .SelLength = Len(.Text) End With End If Application.ScreenUpdating = True End Select End Sub Thank you in advance God bless you . |
Keep Object with Focus on Display Screen
Thanks again, that work like a charm
God bless you -----Original Message----- sure, just set ScrollColumn to 1 ActiveWindow.ScrollColumn = 1 Regards, Tom Ogilvy "andy" wrote in message ... Thank you Tom for your reply, The modified code does do the screen movement I had requested. However when the screen reacts to the forward/backward movement adjusting itself to keep the object on the display screen, it puts the object in the upper left corner of the display and I can't see any of the labels to the left. None of the objects are left alligned. The code works, however can I just send the screen position to the leftmost cell of the row the object is sitting on? Thank you again for you help God bless you -----Original Message----- Untested, but try something like the below modifications. Private Sub cboEnergyType_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) Dim rng as Range Select Case KeyCode Case vbKeyTab, vbKeyReturn, vbKeyDown, vbKeyUp Application.ScreenUpdating = False bBackwards = CBool(Shift And 1) Or (KeyCode = vbKeyUp) If Application.Version < 9 Then Sheet1.Range ("A1").Select If bBackwards Then set rng = Me.txtStopPayComments.TopLeftCell if Intersect (activeWindow.VisibleRange,rng) is nothing then ActiveWindow.ScrollRow = rng.row ActiveWindow.ScrollColumn = rng.column End if With Me.txtStopPayComments .Activate .SelStart = 0 .SelLength = Len(.Text) End With Else set rng = Me.txtAcctNo.TopLeftCell if Intersect (activeWindow.VisibleRange,rng) is nothing then ActiveWindow.ScrollRow = rng.row ActiveWindow.ScrollColumn = rng.column End if With Me.txtAcctNo .Activate .SelStart = 0 .SelLength = Len(.Text) End With End If Application.ScreenUpdating = True End Select End Sub -- Regards, Tom Ogilvy "andy" wrote in message ... I have a page with many objects (textboxes, Option buttons, comboboxes). There are more objects than can fit on the display screen. I have used the code below to tab, shift/tab back and forth between objects on the page Does anyone know how to code to accomplish the following: When a field which I have progressivly tabbed into, is beyond the display screens view (below), I would like the screen to shift down the page so that the object which I have tabbed into, which has the focus (e.g. textbox1.activate) is in my view without me having to scroll down, or do any extra keystrokes. Private Sub cboEnergyType_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer) Select Case KeyCode Case vbKeyTab, vbKeyReturn, vbKeyDown, vbKeyUp Application.ScreenUpdating = False bBackwards = CBool(Shift And 1) Or (KeyCode = vbKeyUp) If Application.Version < 9 Then Sheet1.Range ("A1").Select If bBackwards Then With Me.txtStopPayComments .Activate .SelStart = 0 .SelLength = Len(.Text) End With Else With Me.txtAcctNo .Activate .SelStart = 0 .SelLength = Len(.Text) End With End If Application.ScreenUpdating = True End Select End Sub Thank you in advance God bless you . . |
All times are GMT +1. The time now is 03:41 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com