我在课堂上有家庭作业的调试问题,我做了我认为必要但我得到错误的更改。对于我在消息框中method or data member not found
的代码,它显示shtCurrent.name
。
我已尽可能多地研究,但我找不到答案。任何人都可以帮助我吗?
谢谢。
Public Sub PrintWorksheets1()
'declare variables and assign address to object variable
Dim strPrint As String, wkbHours As Workbook, shtCurrent As Worksheets
Set wkbHours = Application.Workbooks("auco6215_HW10_Ex9.xlsm")
wkbHours.Activate
'ask user if he or she wants to print the worksheet
For Each shtCurrent In wkbHours.Worksheets
strPrint = _
MsgBox(prompt:="Print " & shtCurrent.Name & "?", Buttons:=vbYesNo + vbExclamation)
If strPrint = vbYes Then 'if user wants to print
shtCurrent.PrintPreview
End If
Next shtCurrent
End Sub
答案 0 :(得分:4)
shtCurrent As Worksheets
不应该是工作表 S 集合,只是工作表对象。
Dim strPrint As String, wkbHours As Workbook, shtCurrent As Worksheet