Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default 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



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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



.



  #5   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default 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


.



.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I fix the position of an object on the screen? Bob Arnett Excel Discussion (Misc queries) 0 October 27th 09 05:46 PM
DISPLAY TWO DIFFERENT SHEETS ON SCREEN [email protected] Excel Discussion (Misc queries) 1 March 22nd 09 08:20 PM
How to add a screen tip to an object (no a hyperlink)? Dudealt Excel Discussion (Misc queries) 1 August 8th 08 06:46 PM
The screen should not move to focus on column using when typing Andeamay Excel Discussion (Misc queries) 1 November 7th 05 01:46 AM
Highlight/Select contents of object with focus andy[_5_] Excel Programming 2 January 15th 04 02:44 PM


All times are GMT +1. The time now is 11:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"