繁体   English   中英

问题在工作簿中的工作表中循环

[英]Issue looping through worksheets in a workbook

我在上课时遇到家庭作业的调试问题,我进行了必要的更改,但出现错误。 它说在消息框中method or data member not found为我的代码shtCurrent.name method or data member not found

我已进行了尽可能多的研究,但找不到答案。 谁能帮我吗?

谢谢。

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

shtCurrent As Worksheets不应是工作表S集合,而应仅是工作表对象。

Dim strPrint As String, wkbHours As Workbook, shtCurrent As Worksheet

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM