向页面和框架添加滚动条
以下示例使用 ScrollBars 和 KeepScrollBarsVisible 属性将滚动条添加到 MultiPage 的页面和 Frame。 用户选择了一个选项按钮,该按钮反过来指定 KeepScrollBarsVisible 的值。
若要使用本示例,请将此示例代码复制到窗体的"脚本编辑器"中。 若要运行本代码,需要打开该窗体,以便激活 Open 事件。 确保该窗体包含:
一个名为"MultiPage1"的 MultiPage 。
一个名为"Frame1"的 Frame 。
四个名称分别为"OptionButton1"到"OptionButton4"的 OptionButton 控件。
Sub Item_Open()
Set MultiPage1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("MultiPage1")
Set Frame1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("Frame1")
Set OptionButton1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("OptionButton1")
Set OptionButton2 = Item.GetInspector.ModifiedFormPages("P.2").Controls("OptionButton2")
Set OptionButton3 = Item.GetInspector.ModifiedFormPages("P.2").Controls("OptionButton3")
Set OptionButton4 = Item.GetInspector.ModifiedFormPages("P.2").Controls("OptionButton4")
MultiPage1.Pages(0).ScrollBars = 3 '3=fmScrollBarsBoth
MultiPage1.Pages(0).KeepScrollBarsVisible = 0 '0=fmScrollBarsNone
Frame1.ScrollBars = 3 '3=fmScrollBarsBoth
Frame1.KeepScrollBarsVisible = 0 '0=fmScrollBarsNone
OptionButton1.Caption = "No scroll bars"
OptionButton1.Value = True
OptionButton2.Caption = "Horizontal scroll bars"
OptionButton3.Caption = "Vertical scroll bars"
OptionButton4.Caption = "Both scroll bars"
End Sub
Sub OptionButton1_Click()
Set MultiPage1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("MultiPage1")
Set Frame1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("Frame1")
MultiPage1.Pages(0).KeepScrollBarsVisible = 0 '0=fmScrollBarsNone
Frame1.KeepScrollBarsVisible = 0 '0=fmScrollBarsNonefmScrollBarsNone
End Sub
Sub OptionButton2_Click()
Set MultiPage1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("MultiPage1")
Set Frame1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("Frame1")
MultiPage1.Pages(0).KeepScrollBarsVisible = 1 '1=fmScrollBarsHorizontal
Frame1.KeepScrollBarsVisible = 1 '1=fmScrollBarsHorizontal
End Sub
Sub OptionButton3_Click()
Set MultiPage1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("MultiPage1")
Set Frame1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("Frame1")
MultiPage1.Pages(0).KeepScrollBarsVisible = 2 '2=fmScrollBarsVertical
Frame1.KeepScrollBarsVisible = 2 '2=fmScrollBarsVertical
End Sub
Sub OptionButton4_Click()
Set MultiPage1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("MultiPage1")
Set Frame1 = Item.GetInspector.ModifiedFormPages("P.2").Controls("Frame1")
MultiPage1.Pages(0).KeepScrollBarsVisible = 3 '3=fmScrollBarsBoth
Frame1.KeepScrollBarsVisible = 3 '3=fmScrollBarsBoth
End Sub
支持和反馈
有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。