|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
本帖最后由 Desertsea 于 2012-8-6 13:04 编辑
替你做了一个,不知道是否符合你的口味,当非主页工作表激活时显示工作栏。
在主页,双击单元格进入。
文件索引.rar
(19.06 KB, 下载次数: 176)
- Option Explicit
- Public Const ws_psw As String = "123"
- Sub 打开报表()
- Application.ScreenUpdating = False
- If Sheets("首页").[A1] = "3 1" Then
- ActiveWorkbook.Unprotect Password:=ws_psw
- Sheets("sheet2").Visible = True And Sheets("sheet2").Activate
- ElseIf Sheets("首页").[A1] = "4 1" Then
- ActiveWorkbook.Unprotect Password:=ws_psw
- Sheets("sheet3").Visible = True And Sheets("sheet3").Activate
- ElseIf Sheets("首页").[A1] = "5 1" Then
- ActiveWorkbook.Unprotect Password:=ws_psw
- Sheets("sheet4").Visible = True And Sheets("sheet4").Activate
- ElseIf Sheets("首页").[A1] = "6 1" Then
- ActiveWorkbook.Unprotect Password:=ws_psw
- Sheets("sheet5").Visible = True And Sheets("sheet5").Activate
- End If
- Application.ScreenUpdating = False
- End Sub
- Sub 建立索引()
- Sheets("首页").Cells(3, 1).Value = Sheet2.Name
- Sheets("首页").Cells(4, 1).Value = Sheet3.Name
- Sheets("首页").Cells(5, 1).Value = Sheet4.Name
- Sheets("首页").Cells(6, 1).Value = Sheet5.Name
- End Sub
- Sub 工具栏加载()
- Application.ScreenUpdating = False '关闭屏幕刷新
- Dim arr As Variant
- Dim id As Variant
- Dim i As Integer
- Dim Toolbar As CommandBar
- On Error Resume Next
- Application.CommandBars("MyToolbar").Delete
- arr = Array("返回主页")
- id = Array(1017)
- Set Toolbar = Application.CommandBars.Add("MyToolbar", msoBarTop, , True)
- With Toolbar
- .Protection = msoBarNoResize
- .Visible = True
- For i = 0 To 8
- With .Controls.Add(Type:=msoControlButton)
- .Caption = arr(i)
- .FaceId = id(i)
- .OnAction = arr(i)
- .Style = msoButtonIconAndCaptionBelow
- End With
- Next
- End With
- Set Toolbar = Nothing
- Application.ScreenUpdating = True '关闭屏幕刷新
- End Sub
- Sub 系统卸载()
- Dim j As Integer
- On Error Resume Next
- Application.ScreenUpdating = False '关闭屏幕刷新
- ActiveWorkbook.Unprotect Password:=ws_psw
- Sheets("A").Visible = True
- Sheets("A").Activate
- For j = 1 To Sheets.Count '隐藏所有工作表
- If Sheets(j).Name <> "A" Then Sheets(j).Visible = False
- Next j
- ActiveWorkbook.Protect Password:=ws_psw
- Application.ScreenUpdating = True '关闭屏幕刷新
- End Sub
- Sub 返回主页()
- ActiveWorkbook.Unprotect Password:=ws_psw
- Application.CommandBars("MyToolbar").Delete
- ActiveSheet.Visible = False
- Sheets("首页").Activate
- ActiveWorkbook.Protect Password:=ws_psw
- End Sub
- Sub 系统加载()
- On Error Resume Next '防错
- Application.ScreenUpdating = False '关闭屏幕刷新
- ActiveWorkbook.Unprotect Password:=ws_psw
- With Application
- .AutoRecover.Enabled = False
- .Caption = "123" '更改应用程序名
- Worksheets("首页").Visible = True
- Worksheets("A").Visible = False
- Worksheets("首页").Select
- Application.ScreenUpdating = True
- End With
- End Sub
复制代码
|
|