1.设置focus到第一个sheet的A1单元格。
Sub A1Select()
Dim shcl As Integer
For shcl = Sheets.Count To 1 Step -1
Worksheets(shcl).Activate
Range("A1").Select
ActiveWindow.SmallScroll up:=10485
ActiveWindow.SmallScroll toleft:=100
Next shcl
Worksheets(1).Activate
ActiveWorkbook.Save
End Sub
2.文档保存前执行代码,打印出 test,该段代码必须位于ThisWorkBook(sheet)里面。
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
MsgBox "test"
End Sub
3.文件打开时触发操作,打印出test。
Private Sub Workbook_Open()
Msg = "test"
MsgBox Msg, vbInformation
End Sub