Private Sub hideHeadings()
  Dim obj As Window
  For Each obj In Application.Windows
    obj.DisplayHeadings = False
  Next obj

End Sub


上面是我的尝试,因为当我记录执行此操作的代码时,它变为ActiveWindow.DisplayHeadings = false。但是我一定想念一些东西。请事先帮助谢谢。

最佳答案

我认为除了在每个工作表上进行迭代之外,您无法执行任何其他操作。我用这个代码成功

Private Sub hideHeadings()
  Dim wrkbk As Workbook
  Dim wrksh As Worksheet
  Dim prev As Window

  Set prev = ActiveWindow

  For Each wrkbk In Workbooks
    For Each wrksh In wrkbk.Worksheets
        wrksh.Activate
        ActiveWindow.DisplayHeadings = False
    Next wrksh
  Next wrkbk

  prev.Activate

End Sub

08-19 17:13