Select 工作表方法 class 试图隐藏工作表时失败
Select method of sheets class failed when trying to hide sheets
我正在努力隐藏床单。
我用了两套代码:
Sub hidesheets()
Sheets("Materials - Specifications").Visible = False
Sheets("Fibre drop release sheet").Visible = False
End Sub
接下来
Sub RAtoPDF()
Call hidesheets
Dim sh As Worksheet, sh2 As Worksheet
Dim ArraySheets() As String
Dim custom_name As String
Dim x As Variant
For Each sh In ActiveWorkbook.Worksheets
If sh.Tab.ColorIndex = 33 Then
'Sheets("Materials - Specifications").Visible = False
ReDim Preserve ArraySheets(x)
ArraySheets(x) = sh.Name
x = x + 1
End If
Next sh
Sheets(ArraySheets).Select
custom_name = "RA_" & ThisWorkbook.Name & ".pdf"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
ThisWorkbook.Path & "\" & custom_name, _
Quality:=xlQualityStandard, IncludeDocProperties:=True, _
IgnorePrintAreas:=False, OpenAfterPublish:=True
Sheets("Frontsheet").Select
End Sub
我得到:
Select method of sheets class failed
调试器指向:
Sheets(ArraySheets).Select
我在没有外部宏的情况下尝试了这一行,但错误是一样的。
XlVeryhidden
选项也不起作用。
Select sheets class 方法失败 意味着你 select 用于打印的隐藏 sheet
If sh.Tab.ColorIndex = 33 And sh.Visible = True Then
我正在努力隐藏床单。
我用了两套代码:
Sub hidesheets()
Sheets("Materials - Specifications").Visible = False
Sheets("Fibre drop release sheet").Visible = False
End Sub
接下来
Sub RAtoPDF()
Call hidesheets
Dim sh As Worksheet, sh2 As Worksheet
Dim ArraySheets() As String
Dim custom_name As String
Dim x As Variant
For Each sh In ActiveWorkbook.Worksheets
If sh.Tab.ColorIndex = 33 Then
'Sheets("Materials - Specifications").Visible = False
ReDim Preserve ArraySheets(x)
ArraySheets(x) = sh.Name
x = x + 1
End If
Next sh
Sheets(ArraySheets).Select
custom_name = "RA_" & ThisWorkbook.Name & ".pdf"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
ThisWorkbook.Path & "\" & custom_name, _
Quality:=xlQualityStandard, IncludeDocProperties:=True, _
IgnorePrintAreas:=False, OpenAfterPublish:=True
Sheets("Frontsheet").Select
End Sub
我得到:
Select method of sheets class failed
调试器指向:
Sheets(ArraySheets).Select
我在没有外部宏的情况下尝试了这一行,但错误是一样的。
XlVeryhidden
选项也不起作用。
Select sheets class 方法失败 意味着你 select 用于打印的隐藏 sheet
If sh.Tab.ColorIndex = 33 And sh.Visible = True Then