VBA control vscroll and hscroll in a frame

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to be able to position the vertical and horizontal scroll bars in a
Fame object from VBA. I have searched the internet for an API or code o do
this without success. The only frame routine (scroll) doesn't seem to do
this. Any help would be appreciated.

Gary
 
Hi Gary,

I am not sure I got your point, but you can use the ScrollTop
(Vertical) and ScrollWidth (Horizontal) property to position them. Of
course, you should know the values (in design mode) to do so and also
you should set the Setfocus method to the adjacent object (textbox,
command button, checkbox, etc).

myFrame.ScrollTop = 1176
myFrame.ScrollWidth = 600
myTextBox.SetFocus

I hope this helps.
Karim
 
Please use scrollLeft and not scrollWidth.

ScrollWidth set the width limit for the Frame and ScrollHeight the
height limit.

Regards,
Karim
 
Karim,

I have a WebBrowserObject in a Frame and I need to be able to control from
VBA the position of the scrollbars so the WebBrowser shows what I want. The
scrollbars in the Frame do not appear to be controllable from a VB
application unlike scroll bars you can add to an object. If I try to add my
own scrollbars to the frame it has no affect on the WebBrowser. Hope that
makes sense.

Gary
 
Hello again,

I made an example where you can see how you can programmatically
control the scrollbars in a Frame1. I think this would be better. If
you wish I can send it to your email address.

Regards,
Karim
 
karim,

I would be very grateful to see a real example. Please do send to my email
address.

Thanks for your interest,

gary
 
Is this your email --> gary @ discussions . microsoft . com (I added
the spaces as an anti spamming precaution) ?
 
Hello,

For the benefit of all, here is a description of the program that
worked for Gary.

Create a UserForm1 and add the following objects to it:

A Frame name it as Frame1 with ScrollHeight = 300 and ScrollWidth = 480
A Slider name it as SliderV with Max = 300
A Slider name it as SliderH with Max = 480
A Label name it as V
A Label name it as H

In the code area of the UserForm1 paste the following code:
Private Sub SliderH_Change()
Frame1.ScrollLeft = SliderH.Value
H.Caption = SliderH.Value
End Sub

Private Sub SliderV_Change()
Frame1.ScrollTop = SliderV.Value
V.Caption = SliderV.Value
End Sub

Now, you can control the Frame1 scrollbars using the sliders.

Regards,
Karim
 
Hello,

For the benefit of all, here is a description of the program that
worked for Gary.

Create a UserForm1 and add the following objects to it:

A Frame name it as Frame1 with ScrollHeight = 300 and ScrollWidth = 480
A Slider name it as SliderV with Max = 300
A Slider name it as SliderH with Max = 480
A Label name it as V
A Label name it as H

In the code area of the UserForm1 paste the following code:
Private Sub SliderH_Change()
Frame1.ScrollLeft = SliderH.Value
H.Caption = SliderH.Value
End Sub

Private Sub SliderV_Change()
Frame1.ScrollTop = SliderV.Value
V.Caption = SliderV.Value
End Sub

Now, you can control the Frame1 scrollbars using the sliders.

Regards,
Karim
 
Back
Top