|
Sub Auto_Open() |
|
Dim oToolbar As CommandBar |
|
Dim oButton As CommandBarButton |
|
Dim MyToolbar As String |
|
|
|
' Give the toolbar a name |
|
MyToolbar = "Kewl Tools" |
|
|
|
On Error Resume Next |
|
' so that it doesn't stop on the next line if the toolbar's already there |
|
|
|
' Create the toolbar; PowerPoint will error if it already exists |
|
Set oToolbar = CommandBars.Add(Name:=MyToolbar, _ |
|
Position:=msoBarFloating, Temporary:=True) |
|
If Err.Number <> 0 Then |
|
' The toolbar's already there, so we have nothing to do |
|
Exit Sub |
|
End If |
|
|
|
On Error GoTo ErrorHandler |
|
|
|
' Now add a button to the new toolbar |
|
Set oButton = oToolbar.Controls.Add(Type:=msoControlButton) |
|
|
|
' And set some of the button's properties |
|
|
|
With oButton |
|
|
|
.DescriptionText = "This is my first button" |
|
'Tooltip text when mouse if placed over button |
|
|
|
.Caption = "DCP Bullet Format" |
|
'Text if Text in Icon is chosen |
|
|
|
.OnAction = "dcp_bullets" |
|
'Runs the Sub Button1() code when clicked |
|
|
|
.Style = msoButtonIconAndCaption |
|
' Button displays as icon, not text or both |
|
|
|
.FaceId = 12 |
|
' chooses icon #52 from the available Office icons |
|
|
|
End With |
|
|
|
' Repeat the above for as many more buttons as you need to add |
|
' Be sure to change the .OnAction property at least for each new button |
|
|
|
' You can set the toolbar position and visibility here if you like |
|
' By default, it'll be visible when created. Position will be ignored in PPT 2007 and later |
|
oToolbar.Top = 150 |
|
oToolbar.Left = 150 |
|
oToolbar.Visible = True |
|
|
|
NormalExit: |
|
Exit Sub ' so it doesn't go on to run the errorhandler code |
|
|
|
ErrorHandler: |
|
'Just in case there is an error |
|
MsgBox Err.Number & vbCrLf & Err.Description |
|
Resume NormalExit: |
|
End Sub |
|
|
|
Public Sub dcp_bullets() |
|
Dim Sel As Selection |
|
|
|
Dim lRow As Long ' your i |
|
Dim lCol As Long ' your j |
|
|
|
Set Sel = ActiveWindow.Selection |
|
'need to get textframe of cell of current selection |
|
|
|
|
|
|
|
If Sel.ShapeRange(1).Type = 19 Then |
|
With Sel.ShapeRange(1).Table |
|
For x = 1 To .Rows.Count |
|
For y = 1 To .Columns.Count |
|
If .Cell(x, y).Selected Then |
|
formatBullets .Cell(x, y).Shape.textFrame |
|
End If |
|
Next |
|
Next |
|
End With |
|
Else |
|
formatBullets Sel.ShapeRange(1).textFrame |
|
End If |
|
|
|
|
|
|
|
End Sub |
|
|
|
Sub formatBullets(textFrame As textFrame) |
|
With textFrame |
|
For i = 1 To .TextRange.Paragraphs.Count |
|
With .TextRange.Paragraphs(Start:=i, Length:=1) |
|
.ParagraphFormat.Alignment = ppAlignLeft |
|
.ParagraphFormat.Bullet.Character = 8226 |
|
Select Case .IndentLevel |
|
Case Is = 1 |
|
.Parent.Ruler.Levels(.IndentLevel).FirstMargin = 0 |
|
.Parent.Ruler.Levels(.IndentLevel).LeftMargin = 15 |
|
.Font.Size = 14 |
|
|
|
'TODO: format the bullet itself |
|
'With .ParagraphFormat.Bullet |
|
'.Visible = msoCTrue |
|
'With .Font |
|
'.Name = "WingDings" |
|
'.Size = 14 |
|
'.Color.RGB = bullets_pro |
|
'End With |
|
'.Character = 9650 |
|
'End With |
|
Case Is = 2 |
|
.Parent.Ruler.Levels(.IndentLevel).FirstMargin = 15 |
|
.Parent.Ruler.Levels(.IndentLevel).LeftMargin = 30 |
|
.Font.Size = 12 |
|
Case Is = 3 |
|
.Parent.Ruler.Levels(.IndentLevel).FirstMargin = 30 |
|
.Parent.Ruler.Levels(.IndentLevel).LeftMargin = 45 |
|
.Font.Size = 10 |
|
Case Is = 4 |
|
.Parent.Ruler.Levels(.IndentLevel).FirstMargin = 45 |
|
.Parent.Ruler.Levels(.IndentLevel).LeftMargin = 60 |
|
.Font.Size = 10 |
|
Case Is = 5 |
|
.Parent.Ruler.Levels(.IndentLevel).FirstMargin = 60 |
|
.Parent.Ruler.Levels(.IndentLevel).LeftMargin = 75 |
|
.Font.Size = 10 |
|
Case Is > 5 |
|
.Parent.Ruler.Levels(.IndentLevel).FirstMargin = 75 |
|
.Parent.Ruler.Levels(.IndentLevel).LeftMargin = 90 |
|
.Font.Size = 10 |
|
End Select |
|
End With |
|
Next i |
|
End With |
|
End Sub |
|
|