3

次のコードには何が欠けてい.Captionますか?

Sub SoundLogToolbar()
    Dim cb As CommandBar
    Dim de As CommandBar
    Dim but As CommandBarButton
    Dim picPicture As IPictureDisp

    On Error Resume Next
        MkDir "C:\SoundLog\"
    On Error GoTo 0

    On Error Resume Next
        MkDir "C:\SoundLog\Presentations\"
    On Error GoTo 0

    Set picPicture = stdole.StdFunctions.LoadPicture("C:\SoundLog\Presentations\SoundLog.gif")

    On Error Resume Next
        Application.CommandBars("SoundLog").Delete
    On Error GoTo 0

    Set cb = Application.CommandBars.Add("SoundLog", msoBarTop, , True)

    Set but = CommandBars("SoundLog").Controls.Add(msoControlButton)
    but.Visible = True
    With but
        .Picture = picPicture
        .OnAction = "ShowUserForm"
        .Caption = "SoundLog!"
        .TooltipText = "run this to get data!"
        .Style = msoButtonIconAndCaptionBelow
    End With

    cb.Visible = True
End Sub

ボタンのスタイルでは、msoButtonIconAndCaptionBelow私が望んでいるようなものではなかったのですか?

4

1 に答える 1

2

問題は画像にある可能性があります。256 色の 16x16 の BMP を使用する必要があります (この KB 記事を参照してください)。透明度のためにこれにマスクを設定することもできます。

ただし、上記のコメントから、PowerPoint 2007 でこれを行いたいようです。Office 2007/2010 でこれを行いたい場合は、CommandBar オブジェクトを使用するのではなく、リボン テクノロジを使用する必要があります。これについては、非常に優れた記事があります。VBA を使用している場合、カスタム リボン エディターは不可欠です。VBA を使用して RibbonX を開始するための優れたランディング ページを次に示します (例は Excel 2007 のものですが、PPT/WRD でも同じです)。

于 2010-02-28T08:14:54.993 に答える