我正在尝试使用数组取消隐藏特定的工作表,但出现运行时错误'13'。 正是这一行代码给了我错误:
Worksheets(WS).Visible = True
我设法使用数组隐藏了特定的工作表(我参考工作表的CodeName以避免将来出现引用问题),请参见以下代码:
Sub Hide_sheets_By_CodeName()
Dim Ws_Array As Variant
Set Ws_Array = Sheets(Array(Tiger.Name, Dog.Name, Cat.Name))
Ws_Array.Visible = False
End Sub
要取消隐藏它们,我读到您必须遍历数组中的每个工作表。我为此使用了此代码(这里得到了错误):
Sub UnHide_sheets_By_CodeName()
Dim WS As Worksheet
Dim Ws_Array As Variant
Set Ws_Array = Sheets(Array(Tiger.Name, Dog.Name, Cat.Name))
For Each WS In Ws_Array
Worksheets(WS).Visible = True
Next
End Sub
我们非常感谢您的帮助:)
答案 0 :(得分:1)
WS_Array是类型表的对象,即成员是表。因此404
遇到错误13,因为class PartsList(QListView):
def __init__(self, parent):
super().__init__(parent)
self.setGridSize(QSize(108, 80))
self.partsModel = LibraryModel(self)
for i in image_list:
self.partsModel.appendRow(self.__getPartItem(i))
self.setModel(self.partsModel)
self.setViewMode(self.IconMode)
self.setDragDropMode(self.DragOnly)
def __getPartItem(self, name):
part = QStandardItem()
pixmap = QPixmap(name)
part.setData(pixmap, Qt.DecorationRole)
part.setText(name)
part.setEditable(False)
return part
class LibraryModel(QStandardItemModel):
def __init__(self, parent=None):
QStandardItemModel.__init__(self, parent)
self.setColumnCount(1)
def mimeTypes(self):
return ['part/name']
def DropMimeData(self, idxs):
mimedata = QMimeData()
for idx in idxs:
if idx.isValid():
txt = self.data(idx, Qt.DisplayRole)
mimedata.setText(txt)
mimedata.setData('part/name', txt)
return mimedata
需要一个字符串而不是一个对象。
您可以将for循环更改为
class SchematicView(QGraphicsView):
def __init__(self, parent):
self.scene = SchematicScene()
super().__init__(self.scene, parent)
self.setSceneRect(0, 0, 1, 1)
def dragEnterEvent(self, event):
event.accept()
def dragMoveEvent(self, event):
event.accept()
def dropEvent(self, event):
pass
或
Worksheets(WS).Visible = True