2017-10-11 6 views
-1

& chr(38)のように&をコード化しようとしていますが、その根底には単語の基礎があります。このための任意のソリューションですか?VBAから&ExcelにExcelを印刷するには

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 
+0

これはすべてコードですか?あなたがそれを書いたか、またはchr(38)はmsgboxに "&"を表示します – QHarr

+1

あなたのコードはうまく動作します。 &はあなたが望むように表示します。 – braX

+0

申し訳ありませんが私は上記を更新しました – Lowpar

答えて

1

は確かに通常の動作では、1時間Chr(38)menuitemsで忙しい次の文字の下にあります。 msgboxには、通常のアンパサンドが表示されます。メニュー項目でアンパサンドを文字として使用する場合は、"Exclude P" & Chr(38) & Chr(38) & "S"、または"Exclude P&&S"の2度使用します。

関連する問題