当excel打开时,我试图清除打印区域和自动过滤器:我是Excel vba中的新手,所以从谷歌搜索中组装了以下代码我已经把这个代码放在了XLstart文件夹中Personal.xlsb的ThisWorkbook中,当然宏安全性已设置为启用所有宏
Option Explicit
Public WithEvents xlApp As Excel.Application
Private Sub Workbook_Open()
Set xlApp = Application
End Sub
Private Sub Workbook_Close()
Set xlApp = Nothing
End Sub
Private Sub xlApp_WorkbookOpen(ByVal Wb As Workbook)
Application.EnableEvents = False
Call ClrPrntArea
Application.EnableEvents = True
End Sub
这是 ClrPrntArea
Sub ClrPrntArea()
Dim ws As Object
For i = 1 To ActiveWorkbook.Worksheets.count
With Worksheets(i)
.PageSetup.PrintArea = ""
.PageSetup.FitToPagesWide = 1
End With
Next
End Sub
一旦上面开始工作,我还将在个人 xlsb 中对模块进行另一个宏调用,以重置自动调整器。任何输入都会非常有帮助