2010-02-25 5 views
2

.Caption은 맨 아래에 아이콘과 아이콘이 표시되어 다음 코드에 무엇이 누락 되었습니까? msoButtonIconAndCaptionBelow 버튼 스타일로VBA를 사용하여 아이콘 아래에 캡션이있는 툴바 버튼을 만드는 방법은 무엇입니까?

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 

, 내가 원하는처럼되고 가정되지 않았다?

+0

사진이 포함 된 디렉토리를 만들었지 만 디렉토리에 gif를 복사하지 않으면 어떻게 사진을 찾을 수 있는지 알 수 없습니다. – Fionnuala

+0

오, 그건 다른 하위에서 복사/과거. 그것과 함께하지 마십시오. 이 코드를 사용하면 단추와 도구 모음이 만들어 지지만 단추의 왼쪽에는 작은 아이콘과 캡션이 있습니다. Powerpoint2007의 "New Slide"와 같은 버튼을 만들고 싶습니다. (아래 캡션이있는 큰 아이콘) ---> msoButtonIconAndCaptionBelow –

답변

1

사진에 문제가있을 수 있습니다. BMP 16x16 및 256 색 (this KB article 참조)을 사용해야합니다. 투명도를 위해 마스크를 설정할 수도 있습니다.

그러나 위의 의견에서 PowerPoint 2007에 대해이 작업을 수행하려는 것으로 보입니다. Office 2007/2010에서이 작업을 수행하려는 경우 CommandBar 개체를 더 이상 사용하지 말고 리본 기술. this에 관한 정말 좋은 기사가 있습니다. VBA를 사용하는 경우 Custom Ribbon Editor은 필수적이며 here's a great landing page을 사용하면 VBA에서 RibbonX를 시작할 수 있습니다 (Excel 2007의 예는 PPT/WRD의 경우와 같습니다).

관련 문제