我尝试编写一个函数来获取另一个工作簿的页数。但是,在下面的代码中,位于wb.Sheets.Count的调试会引发错误。请帮助我返回另一本工作簿的页数(在wb参考中)。
Function GetSheetCount(XlsFileName As String) As Integer
'Application.ScreenUpdating = False
Dim wb As Workbook
'Dim ws As Worksheet
'Dim i As Integer
'i = 0
Set wb = Workbooks.Open(XlsFileName)
'For Each ws In wb.Sheets
'i = i + 1
'Next ws
GetSheetCount = wb.Sheets.Count'i
'wb.Close False
'Application.ScreenUpdating = True
End Function