如何打印&从VBA到Excel

时间:2017-10-11 13:13:21

标签: vba excel-vba excel

我一直在尝试编码&,就像在角色和& chr(38),但它始终坚持这个词。对此有何解决方案?

Private Sub createMenu()
'define the variables
    Dim mnuDownload1 As Menu

    'create the menue bar
    With MenuBars(xlWorksheet)
        .Reset
        .Menus.Add "Import", 1

        'define the menue bar
        Set mnuDownload1 = MenuBars(xlWorksheet).Menus("Import")

        'for each defined menu bar at the sub item , the first "" is the name of the item. The second "" is the macro name
        With mnuDownload1.MenuItems
         .AddMenu Caption:="P&S"
         .Item("P&S").MenuItems.Add "Exclude P" & Chr(38) & "S", "changes"
        End With
End With
End Sub

1 个答案:

答案 0 :(得分:1)

确实是正常行为,在class Window(QMainWindow): [...] def Table_of_widgets(self): [...] list1 = [...] self.d = {" ": [" "]} self.d_inverse = {" ": [" "]} def createData(key1, key2, data): if key2 not in data[" "]: data[" "].append(key2) if key1 in data.keys(): if key2 not in data[key1]: data[key1].append(key2) else: data[key1] = [" ", key2] return data for item in list1: item1 = item[0] item2 = item[2] self.d = createData(item1, item2, self.d) self.d_inverse = createData(item2, item1, self.d_inverse) for i in range(rowCount): comboA = QComboBox() comboB = QComboBox() comboA.addItems(self.d.keys()) comboB.addItems(self.d[comboA.currentText()]) self.table.setCellWidget(i, 0, comboA) self.table.setCellWidget(i, 1, comboB) comboA.currentTextChanged.connect(lambda text, row=i: self.onComboACurrentTextChanged(text, row)) comboB.currentTextChanged.connect(lambda text, row=i: self.onComboBCurrentTextChanged(text, row)) def updateCombox(self, combo1, combo2, item1, item2): text = combo1.currentText() combo1.blockSignals(True) combo2.blockSignals(True) combo1.clear() combo2.clear() combo2.addItems(item1[text]) combo2.setCurrentIndex(1 if text != " " else 0) combo1.addItems(item2[combo2.currentText()]) combo1.setCurrentText(text) combo1.blockSignals(False) combo2.blockSignals(False) def onComboACurrentTextChanged(self, text, row): comboA = self.table.cellWidget(row, 0) comboB = self.table.cellWidget(row, 1) self.updateCombox(comboA, comboB, self.d, self.d_inverse) def onComboBCurrentTextChanged(self, text, row): comboA = self.table.cellWidget(row, 0) comboB = self.table.cellWidget(row, 1) self.updateCombox(comboB, comboA, self.d_inverse, self.d) 忙碌时,一次Chr(38)是下一个角色的基础。 menuitems将显示正常的&符号。如果您想将&符号用作menuitem中的字符,请在msgbox"Exclude P" & Chr(38) & Chr(38) & "S"中使用两次。