Я пытаюсь сделать кнопку переключения на панели команд, но я сталкиваюсь с двумя проблемами 1) Она продолжает выполнять 'removebleed', а не переключаться между ними. 2) не показывает переключаемую кнопку. Сначала я прикрепил код кнопки меню, затем код для кнопки. Большое спасибо за любую помощь, Джей
Set ToggleButton = oToolbar.Controls.Add(Type:=msoControlButton)
With ToggleButton
.DescriptionText = "Switch bleed on or off"
.Caption = "Bleed on/off"
.OnAction = "ToggleButton"
.Style = msoButtonCaption
End With
Sub ToggleButton()
Static Toggle As Boolean
If Toggle = True Then
With Application.CommandBars.ActionControl
.State = Not .State
End With
Toggle = False ' changes the variable so next time it unpresses the button and runs the other macro
AddBleed
Else
RemoveBleed
End If
End Sub
Sub AddBleed()
Dim WidthBleed As String
Dim HeightBleed As String
WidthBleed = 0.125 * 72
HeightBleed = 0.25 * 72
SWidth = ActivePresentation.PageSetup.SlideWidth
SHeight = ActivePresentation.PageSetup.SlideHeight
With Application.ActivePresentation.PageSetup
.SlideWidth = SWidth + WidthBleed
.SlideHeight = SHeight + HeightBleed
End With
End Sub
Sub RemoveBleed()
Dim WidthBleed As String
Dim HeightBleed As String
Dim SWidth As String
Dim SHeight As String
WidthBleed = 0.125 * 72
HeightBleed = 0.25 * 72
SWidth = ActivePresentation.PageSetup.SlideWidth
SHeight = ActivePresentation.PageSetup.SlideHeight
With Application.ActivePresentation.PageSetup
.SlideWidth = SWidth - WidthBleed
.SlideHeight = SHeight - HeightBleed
End With
End Sub