laufzeitfehler 13 typen unverträglich

  • PowerPoint

Es gibt 6 Antworten in diesem Thema. Der letzte Beitrag () ist von Luca.

    laufzeitfehler 13 typen unverträglich

    Hallo,

    ich bräuchte dringend Hilfe. Ich bekomme die Fehlermeldung "laufzeitfehler 13 typen unverträglich".

    Beim Debuggen erhalte ich an folgenden tellen einen Fehler:

    Sub showSettingDialog()

    settingsForm.Show

    End Sub

    und hier:

    Private Sub UserForm_Initialize()

    topPos.Value = GetSetting(appname:="PogressBar", Section:="PosPogressBar", Key:="topPos")

    leftPos.Value = GetSetting(appname:="PogressBar", Section:="PosPogressBar", Key:="leftPos")

    sizeOfBullet.Value = GetSetting(appname:="PogressBar", Section:="PosPogressBar", Key:="sizeOfBullet")

    spaceBetweenBullets.Value = GetSetting(appname:="PogressBar", Section:="PosPogressBar", Key:="spaceBetweenBullets")

    wraparound.Value = GetSetting(appname:="PogressBar", Section:="PosPogressBar", Key:="wraparound")

    wraparoundlimit.Value = GetSetting(appname:="PogressBar", Section:="PosPogressBar", Key:="wraparoundlimit")



    Debug.Print GetSetting(appname:="PogressBar", Section:="PosPogressBar", Key:="OptionHorizontal")

    Debug.Print CBool(GetSetting(appname:="PogressBar", Section:="PosPogressBar", Key:="OptionHorizontal"))

    Der Code lautet:

    'Option Explicit
    Private Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    Private Declare PtrSafe Function LockWindowUpdate Lib "user32" (ByVal hWndLock As Long) As Long
    Private Declare PtrSafe Function UpdateWindow Lib "user32" (ByVal hWnd As Long) As Long

    Declare PtrSafe Function ChooseColor Lib "comdlg32.dll" _
    Alias "ChooseColorA" ( _
    lpcc As CHOOSECOLOR_TYPE) As Long

    Private Type CHOOSECOLOR_TYPE
    lStructSize As Long
    hwndOwner As Long
    hInstance As Long
    rgbResult As Long
    lpCustColors As Long
    flags As Long
    lCustData As Long
    lpfnHook As Long
    lpTemplateName As String
    End Type

    ' Anwender kann alle Farben wählen
    Private Const CC_ANYCOLOR = &H100
    ' Nachrichten können "abgefangen" werden
    Private Const CC_ENABLEHOOK = &H10
    ' Dialogbox Template
    Private Const CC_ENABLETEMPLATE = &H20
    ' Benutzt Template, ignoriert aber den Template-Namen
    Private Const CC_ENABLETEMPLATEHANDLE = &H40
    ' Vollauswahl aller Farben anzeigen
    Private Const CC_FULLOPEN = &H2
    ' Deaktiviert den Button zum Öffnen der Dialogbox-Erweiterung
    Private Const CC_PREVENTFULLOPEN = &H4
    ' Vorgabe einer Standard-Farbe
    Private Const CC_RGBINIT = &H1
    ' Hilfe-Button anzeigen
    Private Const CC_SHOWHELP = &H8
    ' nur Grundfarben auswählbar
    Private Const CC_SOLIDCOLOR = &H80

    Sub Example_ScreenUpdating()
    ScreenUpdating(FindWindowHandle(Application)) = True 'or False
    End Sub

    Property Let ScreenUpdating(Optional ByVal hWnd As Long, ByVal State As Boolean)
    If Not State Then
    LockWindowUpdate hWnd
    Else
    LockWindowUpdate False
    UpdateWindow hWnd
    End If
    End Property

    Function FindWindowHandle(ByVal App As Object, Optional ByVal Caption As String) As Long
    If App Is Nothing Then
    FindWindowHandle = FindWindow(vbNullString, Caption)
    Else
    On Error Resume Next
    Select Case App.Name
    Case "Microsoft Access"
    'Caption = App.Name
    FindWindowHandle = FindWindow("OMAIN", Caption)
    Case "Microsoft Excel"
    'Caption = App.Caption
    FindWindowHandle = FindWindow("XLMAIN", Caption)
    Case "Microsoft PowerPoint"
    Select Case Val(Application.Version)
    Case 8
    FindWindowHandle = FindWindow("PP97FrameClass", Caption)
    Case 9 To 12
    'Caption = App.Caption & " - [" & App.ActiveWindow.Caption & "]"
    FindWindowHandle = FindWindow("PP" & Val(Application.Version) & "FrameClass", _
    Caption)
    Case Else
    'Caption = App.Caption
    FindWindowHandle = FindWindow("PPTFrameClass", Caption)
    End Select
    Case "Microsoft Word"
    'Caption = App.ActiveWindow.Caption & " - " & App.Caption
    FindWindowHandle = FindWindow("OPUSAPP", Caption)
    Case "Outlook"
    'Caption = Application.ActiveExplorer.Caption
    FindWindowHandle = FindWindow("rctrl_renwnd32", Caption)
    Case Else
    'Userform
    'Caption = App.Caption
    If Val(Application.Version) >= 9 Then
    FindWindowHandle = FindWindow("ThunderDFrame", Caption)
    Else
    FindWindowHandle = FindWindow("ThunderXFrame", Caption)
    End If
    End Select
    End If
    End Function

    Sub Auto_Open()
    Dim oToolbar As CommandBar
    Dim oButton As CommandBarButton
    Dim MyToolbar As String

    ' Give the toolbar a name
    MyToolbar = "Progress Addin"

    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 = "Add Progress Bar"
    'Tooltip text when mouse if placed over button
    .Caption = "AddDetailedProgressBar"
    'Text if Text in Icon is chosen
    .OnAction = "AddDetailedProgressBar"
    'Runs the Sub Button1() code when clicked
    .Style = msoButtonIcon
    ' Button displays as icon, not text or both
    .FaceId = 35
    '52 is my favorite pig;
    ' chooses icon #52 from the available Office icons
    End With

    ' 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 = "Remove Progress Bar"
    'Tooltip text when mouse if placed over button
    .Caption = "RemoveDetailedProgressBar"
    'Text if Text in Icon is chosen
    .OnAction = "RemoveDetailedProgressBar"
    'Runs the Sub Button1() code when clicked
    .Style = msoButtonIcon
    ' Button displays as icon, not text or both
    .FaceId = 67
    '52 is my favorite pig;
    ' chooses icon #52 from the available Office icons
    End With

    ' 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 = "Add Section"
    'Tooltip text when mouse if placed over button
    .Caption = "AddSection"
    'Text if Text in Icon is chosen
    .OnAction = "AddSection"
    'Runs the Sub Button1() code when clicked
    .Style = msoButtonIcon
    ' Button displays as icon, not text or both
    .FaceId = 137
    '52 is my favorite pig;
    ' chooses icon #52 from the available Office icons
    End With

    ' 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 = "Remove Section"
    'Tooltip text when mouse if placed over button
    .Caption = "RemoveSection"
    'Text if Text in Icon is chosen
    .OnAction = "RemoveSection"
    'Runs the Sub Button1() code when clicked
    .Style = msoButtonIcon
    ' Button displays as icon, not text or both
    .FaceId = 138
    '52 is my favorite pig;
    ' chooses icon #52 from the available Office icons
    End With

    ' 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 = "Add Ignore Slide"
    'Tooltip text when mouse if placed over button
    .Caption = "AddIgnoreSlide"
    'Text if Text in Icon is chosen
    .OnAction = "AddIgnoreSlide"
    'Runs the Sub Button1() code when clicked
    .Style = msoButtonIcon
    ' Button displays as icon, not text or both
    .FaceId = 214
    '52 is my favorite pig;
    ' chooses icon #52 from the available Office icons
    End With



    ' 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 = "Remove Ignore Slide"
    'Tooltip text when mouse if placed over button
    .Caption = "RemoveIgnoreSlide"
    'Text if Text in Icon is chosen
    .OnAction = "RemoveIgnoreSlide"
    'Runs the Sub Button1() code when clicked
    .Style = msoButtonIcon
    ' Button displays as icon, not text or both
    .FaceId = 213
    '52 is my favorite pig;
    ' chooses icon #52 from the available Office icons
    End With


    ' 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 = "Clear Structure"
    'Tooltip text when mouse if placed over button
    .Caption = "Delete old structure"
    'Text if Text in Icon is chosen
    .OnAction = "ClearOldStructure"
    'Runs the Sub Button1() code when clicked
    .Style = msoButtonIcon
    ' Button displays as icon, not text or both
    .FaceId = 215
    '52 is my favorite pig;
    ' chooses icon #52 from the available Office icons
    End With


    ' 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 = "Show Settings Dialog"
    'Tooltip text when mouse if placed over button
    .Caption = "Show Settings"
    'Text if Text in Icon is chosen
    .OnAction = "showSettingDialog"
    'Runs the Sub Button1() code when clicked
    .Style = msoButtonIcon
    ' Button displays as icon, not text or both
    .FaceId = 44
    '52 is my favorite pig;
    ' chooses icon #52 from the available Office icons
    End With

    ' 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 = "Show Info Dialog"
    'Tooltip text when mouse if placed over button
    .Caption = "Show Info"
    'Text if Text in Icon is chosen
    .OnAction = "showInfoDialog"
    'Runs the Sub Button1() code when clicked
    .Style = msoButtonIcon
    ' Button displays as icon, not text or both
    .FaceId = 124
    '52 is my favorite pig;
    ' 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
    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

    Sub showSettingDialog()

    settingsForm.Show
    End Sub

    Sub showInfoDialog()

    helpForm.Show

    End Sub

    Sub AddSection()
    On Error Resume Next
    Dim presentation As Object
    Dim s As PowerPoint.Shape
    presentation = Application.ActivePresentation

    Set s = Application.ActiveWindow.Selection.SlideRange.Shapes.AddShape(msoShapeRectangle, 10, 10, 10, 10)
    s.Name = "section"
    s.Visible = False

    Application.ActiveWindow.Selection.SlideRange.Comments.Add 0, 0, "", "", "Section"


    End Sub

    Sub AddIgnoreSlide()
    On Error Resume Next
    Dim presentation As Object
    Dim s As PowerPoint.Shape
    presentation = Application.ActivePresentation

    Application.ActiveWindow.Selection.SlideRange.NotesPage.Tags.Add "Ignore", "True"
    Set s = Application.ActiveWindow.Selection.SlideRange.Shapes.AddShape(msoShapeRectangle, 10, 10, 10, 10)
    s.Name = "ignore"
    s.Visible = False

    Application.ActiveWindow.Selection.SlideRange.Comments.Add 0, 0, "", "", "Ignore"
    End Sub

    Sub RemoveSection()
    On Error Resume Next
    Dim currentSlide As slide
    'Dim currSlideNum As Integer

    'currSlideNum = ActiveWindow.View.Slide.SlideIndex
    'Set currentSlide = ActiveWindow.Selection.SlideRange.Item(currSlideNum)
    'Set currentSlide = ActivePresentation.Slides(currSlideNum)


    Set currentSlide = ActivePresentation.Slides(ActiveWindow.View.slide.Name)



    With currentSlide
    .Shapes("section").Delete
    .Comments.Item(1).Delete
    End With
    End Sub

    Sub RemoveIgnoreSlide()
    On Error Resume Next
    Dim currentSlide As slide

    Set currentSlide = ActivePresentation.Slides(ActiveWindow.View.slide.Name)

    With currentSlide
    .Shapes("ignore").Delete
    .Comments.Item(1).Delete
    End With
    End Sub

    Sub AddDetailedProgressBar()

    ScreenUpdating(FindWindowHandle(Application)) = False
    RemoveDetailedProgressBar


    On Error Resume Next
    Dim presentation As PowerPoint.presentation
    Dim s As PowerPoint.Shape
    Set presentation = Application.ActivePresentation
    Dim counter As Integer: counter = 0
    Dim slide As slide


    Dim X As Integer: X = 0
    Dim initialTop As Integer: initialTop = 0
    Dim initialLeft As Integer: initialLeft = 0
    Dim bulletCounter As Integer: bulletCounter = 0
    Dim Count As Integer: Count = 0


    Dim sectionCounter As Integer: sectionCounter = 0
    Dim slidesPerSection As Integer: slidesPerSection = 0
    Dim numberOfSections As Integer: numberOfSections = 0
    Dim sectionLength As Variant: sectionLength = 0

    Dim mySections() As Integer
    Dim sectionSlides() As Integer
    ReDim Preserve mySections(0 To 1)
    ReDim Preserve sectionSlides(0 To 1)


    ' Determine structure of slide set
    With presentation
    For X = 1 To .Slides.Count
    Dim notHidden As Boolean
    notHidden = Not .Slides(X).SlideShowTransition.Hidden

    Dim notIgnored As Boolean


    If .Slides(X).NotesPage.Tags.Count = 0 Then
    notIgnored = True
    Else
    notIgnored = False
    End If



    If notHidden And notIgnored Then
    'get slide numbers
    ReDim Preserve sectionSlides(0 To (UBound(sectionSlides) + 1))

    sectionSlides(counter) = .Slides(X).slideNumber


    counter = counter + 1
    If IsNull(.Slides(X).Shapes("section")) Then
    mySections(sectionCounter) = mySections(sectionCounter) + 1
    Else
    ReDim Preserve mySections(0 To (UBound(mySections) + 1))
    sectionCounter = sectionCounter + 1
    mySections(sectionCounter) = 1
    End If

    End If
    Next X
    End With

    'load from settings
    Dim left As Integer: left = CInt(GetSetting(appname:="PogressBar", Section:="PosPogressBar", Key:="leftPos"))
    Dim top As Integer: top = presentation.PageSetup.SlideHeight - CInt(GetSetting(appname:="PogressBar", Section:="PosPogressBar", Key:="topPos"))
    Dim sizeOfBullet As Integer: sizeOfBullet = CInt(GetSetting(appname:="PogressBar", Section:="PosPogressBar", Key:="sizeOfBullet"))
    Dim spaceBetweenBullets As Integer: spaceBetweenBullets = CInt(GetSetting(appname:="PogressBar", Section:="PosPogressBar", Key:="spaceBetweenBullets"))
    Dim maxleft As Integer: maxleft = CInt(GetSetting(appname:="PogressBar", Section:="PosPogressBar", Key:="wraparound"))
    Dim wraparoundoffset As Integer: wraparoundoffset = CInt(GetSetting(appname:="PogressBar", Section:="PosPogressBar", Key:="wraparoundlimit"))
    Dim colorRed As Integer: colorRed = CInt(GetSetting(appname:="PogressBar", Section:="PosPogressBar", Key:="colorRed"))
    Dim colorYellow As Integer: colorYellow = CInt(GetSetting(appname:="PogressBar", Section:="PosPogressBar", Key:="colorYellow"))
    Dim colorBlue As Integer: colorBlue = CInt(GetSetting(appname:="PogressBar", Section:="PosPogressBar", Key:="colorBlue"))
    Dim vertical As Boolean: vertical = CBool(GetSetting(appname:="PogressBar", Section:="PosPogressBar", Key:="OptionVertical"))



    'init if fields are null
    If IsNull(left) Then
    left = 20
    End If

    'init if fields are null
    If IsNull(maxleft) Then
    left = 500
    End If

    If IsNull(top) Then
    top = 50
    End If

    If IsNull(sizeOfBullet) Then
    sizeOfBullet = 6
    End If

    If IsNull(spaceBetweenBullets) Then
    spaceBetweenBullets = 8
    End If

    'init if fields are null
    If IsNull(wraparoundoffset) Then
    wraparoundoffset = 2 * sizeOfBullet
    End If

    initialLeft = left
    initialTop = top



    With presentation
    Dim currentSlideNumber As Integer: currentSlideNumber = 0

    For Each slide In .Slides

    'bullet counter needed to do wrap arround
    bulletCounter = 0
    left = initialLeft
    top = initialTop

    Dim slideNumber As Integer: slideNumber = 0

    'Dim notHidden As Boolean: notHidden = Slide.SlideShowTransition.Hidden = Microsoft.Office.Core.MsoTriState.msoFalse
    notHidden = Not slide.SlideShowTransition.Hidden
    'Dim notIgnored As Boolean

    notIgnored = True

    If slide.NotesPage.Tags.Count = 0 Then
    notIgnored = True
    Else
    notIgnored = False
    End If

    If notHidden And notIgnored Then

    For Each sectionLength In mySections

    If vertical Then
    If top > maxleft Then
    left = left + wraparoundoffset
    top = initialLeft
    End If
    Else
    If left > maxleft Then
    top = top + wraparoundoffset
    left = initialLeft
    End If
    End If

    For Count = 1 To sectionLength
    bulletCounter = bulletCounter + 1
    Set s = slide.Shapes.AddShape(msoShapeOval, left, top, sizeOfBullet, sizeOfBullet)
    s.Name = "PB_" & CStr(slideNumber)

    If currentSlideNumber = slideNumber Then
    s.Fill.ForeColor.RGB = RGB(colorRed, colorYellow, colorBlue)
    s.Line.ForeColor.RGB = RGB(colorRed, colorYellow, colorBlue)
    Else
    s.Fill.ForeColor.RGB = RGB(220, 220, 220)
    s.Line.ForeColor.RGB = RGB(150, 150, 150)
    End If
    With s.ActionSettings(ppMouseClick)
    .Action = ppActionNamedSlideShow
    With .Hyperlink
    '.Address = Me.Application.ActivePresentation.FullName
    .SubAddress = CStr(sectionSlides(slideNumber))
    .Follow
    End With
    End With
    slideNumber = slideNumber + 1
    If vertical Then
    top = top + spaceBetweenBullets
    Else
    left = left + spaceBetweenBullets
    End If
    Next Count

    If vertical Then
    top = top + spaceBetweenBullets
    Else
    left = left + spaceBetweenBullets
    End If


    Next sectionLength
    'slide.Shapes("PB").Delete()
    currentSlideNumber = currentSlideNumber + 1
    End If
    Next
    End With

    ScreenUpdating(FindWindowHandle(Application)) = True

    End Sub

    Sub RemoveDetailedProgressBar()

    Dim presentation As PowerPoint.presentation
    Set presentation = Application.ActivePresentation
    Dim X As Integer: X = 0

    Dim slide As slide

    With presentation
    For Each slide In .Slides
    For X = 0 To slide.Shapes.Count
    On Error Resume Next
    'Debug.Print slide.Shapes.Count
    Debug.Print slide.Shapes(X).Name
    slide.Shapes("PB_" & CStr(X)).Delete
    Next
    Next
    End With
    End Sub

    Sub ClearOldStructure()

    Dim presentation As PowerPoint.presentation
    Set presentation = Application.ActivePresentation

    Dim slide As slide

    With presentation
    For Each slide In .Slides
    On Error Resume Next
    With slide
    .Shapes("ignore").Delete
    .Comments.Item(1).Delete
    .Shapes("section").Delete
    .Comments.Item(1).Delete
    End With

    For X = 0 To slide.Shapes.Count
    On Error Resume Next
    slide.Shapes("PB_" & CStr(X)).Delete
    Next
    Next
    End With
    End Sub

    Sub ShowFaceIDs()
    Dim NewToolbar As CommandBar
    Dim NewButton As CommandBarButton
    Dim i As Integer, IDStart As Integer, IDStop As Integer

    ' Delete existing FaceIds toolbar if it exists
    On Error Resume Next
    Application.CommandBars("FaceIds").Delete
    On Error GoTo 0

    ' Add an empty toolbar
    Set NewToolbar = Application.CommandBars.Add _
    (Name:="FaceIds", temporary:=True)
    NewToolbar.Visible = True

    ' Change the following values to see different FaceIDs
    IDStart = 1
    IDStop = 250

    For i = IDStart To IDStop
    'Set NewButton = NewToolbar.Add(Type:=msoControlButton, Id:=2950)
    Set NewButton = NewToolbar.Controls.Add(Type:=msoControlButton)
    NewButton.FaceId = i
    NewButton.Caption = "FaceID = " & i
    Next i
    NewToolbar.Width = 600
    End Sub


    Vielen Dank im Voraus
    Bitte verwende Codetags das man das lesen kann. Vorallem wenns soviel ist.. versuch es vll. so zu darzustellen, dass man keine halbe Stunde braucht um es nachvollziehen zu können.
    Das ist meine Signatur und sie wird wunderbar sein!
    Guten Morgen. Das tut mir leid.


    Quellcode

    1. 'Option Explicit
    2. Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    3. Declare PtrSafe Function LockWindowUpdate Lib "user32" (ByVal hWndLock As Long) As Long
    4. Declare PtrSafe Function UpdateWindow Lib "user32" (ByVal hWnd As Long) As Long
    5. Declare PtrSafe Function ChooseColor Lib "comdlg32.dll" _
    6. Alias "ChooseColorA" ( _
    7. lpcc As CHOOSECOLOR_TYPE) As Long
    8. Private Type CHOOSECOLOR_TYPE
    9. lStructSize As Long
    10. hwndOwner As Long
    11. hInstance As Long
    12. rgbResult As Long
    13. lpCustColors As Long
    14. flags As Long
    15. lCustData As Long
    16. lpfnHook As Long
    17. lpTemplateName As String
    18. End Type
    19. ' Anwender kann alle Farben wählen
    20. Private Const CC_ANYCOLOR = &H100
    21. ' Nachrichten können "abgefangen" werden
    22. Private Const CC_ENABLEHOOK = &H10
    23. ' Dialogbox Template
    24. Private Const CC_ENABLETEMPLATE = &H20
    25. ' Benutzt Template, ignoriert aber den Template-Namen
    26. Private Const CC_ENABLETEMPLATEHANDLE = &H40
    27. ' Vollauswahl aller Farben anzeigen
    28. Private Const CC_FULLOPEN = &H2
    29. ' Deaktiviert den Button zum Öffnen der Dialogbox-Erweiterung
    30. Private Const CC_PREVENTFULLOPEN = &H4
    31. ' Vorgabe einer Standard-Farbe
    32. Private Const CC_RGBINIT = &H1
    33. ' Hilfe-Button anzeigen
    34. Private Const CC_SHOWHELP = &H8
    35. ' nur Grundfarben auswählbar
    36. Private Const CC_SOLIDCOLOR = &H80
    37. Sub Example_ScreenUpdating()
    38. ScreenUpdating(FindWindowHandle(Application)) = True 'or False
    39. End Sub
    40. Property Let ScreenUpdating(Optional ByVal hWnd As Long, ByVal State As Boolean)
    41. If Not State Then
    42. LockWindowUpdate hWnd
    43. Else
    44. LockWindowUpdate False
    45. UpdateWindow hWnd
    46. End If
    47. End Property
    48. Function FindWindowHandle(ByVal App As Object, Optional ByVal Caption As String) As Long
    49. If App Is Nothing Then
    50. FindWindowHandle = FindWindow(vbNullString, Caption)
    51. Else
    52. On Error Resume Next
    53. Select Case App.Name
    54. Case "Microsoft Access"
    55. 'Caption = App.Name
    56. FindWindowHandle = FindWindow("OMAIN", Caption)
    57. Case "Microsoft Excel"
    58. 'Caption = App.Caption
    59. FindWindowHandle = FindWindow("XLMAIN", Caption)
    60. Case "Microsoft PowerPoint"
    61. Select Case Val(Application.Version)
    62. Case 8
    63. FindWindowHandle = FindWindow("PP97FrameClass", Caption)
    64. Case 9 To 12
    65. 'Caption = App.Caption & " - [" & App.ActiveWindow.Caption & "]"
    66. FindWindowHandle = FindWindow("PP" & Val(Application.Version) & "FrameClass", _
    67. Caption)
    68. Case Else
    69. 'Caption = App.Caption
    70. FindWindowHandle = FindWindow("PPTFrameClass", Caption)
    71. End Select
    72. Case "Microsoft Word"
    73. 'Caption = App.ActiveWindow.Caption & " - " & App.Caption
    74. FindWindowHandle = FindWindow("OPUSAPP", Caption)
    75. Case "Outlook"
    76. 'Caption = Application.ActiveExplorer.Caption
    77. FindWindowHandle = FindWindow("rctrl_renwnd32", Caption)
    78. Case Else
    79. 'Userform
    80. 'Caption = App.Caption
    81. If Val(Application.Version) >= 9 Then
    82. FindWindowHandle = FindWindow("ThunderDFrame", Caption)
    83. Else
    84. FindWindowHandle = FindWindow("ThunderXFrame", Caption)
    85. End If
    86. End Select
    87. End If
    88. End Function
    89. Sub Auto_Open()
    90. Dim oToolbar As CommandBar
    91. Dim oButton As CommandBarButton
    92. Dim MyToolbar As String
    93. ' Give the toolbar a name
    94. MyToolbar = "Progress Addin"
    95. On Error Resume Next
    96. ' so that it doesn't stop on the next line if the toolbar's already there
    97. ' Create the toolbar; PowerPoint will error if it already exists
    98. Set oToolbar = CommandBars.Add(Name:=MyToolbar, _
    99. Position:=msoBarFloating, temporary:=True)
    100. If Err.Number <> 0 Then
    101. ' The toolbar's already there, so we have nothing to do
    102. Exit Sub
    103. End If
    104. On Error GoTo ErrorHandler
    105. ' Now add a button to the new toolbar
    106. Set oButton = oToolbar.Controls.Add(Type:=msoControlButton)
    107. ' And set some of the button's properties
    108. With oButton
    109. .DescriptionText = "Add Progress Bar"
    110. 'Tooltip text when mouse if placed over button
    111. .Caption = "AddDetailedProgressBar"
    112. 'Text if Text in Icon is chosen
    113. .OnAction = "AddDetailedProgressBar"
    114. 'Runs the Sub Button1() code when clicked
    115. .Style = msoButtonIcon
    116. ' Button displays as icon, not text or both
    117. .FaceId = 35
    118. '52 is my favorite pig;
    119. ' chooses icon #52 from the available Office icons
    120. End With
    121. ' Now add a button to the new toolbar
    122. Set oButton = oToolbar.Controls.Add(Type:=msoControlButton)
    123. ' And set some of the button's properties
    124. With oButton
    125. .DescriptionText = "Remove Progress Bar"
    126. 'Tooltip text when mouse if placed over button
    127. .Caption = "RemoveDetailedProgressBar"
    128. 'Text if Text in Icon is chosen
    129. .OnAction = "RemoveDetailedProgressBar"
    130. 'Runs the Sub Button1() code when clicked
    131. .Style = msoButtonIcon
    132. ' Button displays as icon, not text or both
    133. .FaceId = 67
    134. '52 is my favorite pig;
    135. ' chooses icon #52 from the available Office icons
    136. End With
    137. ' Now add a button to the new toolbar
    138. Set oButton = oToolbar.Controls.Add(Type:=msoControlButton)
    139. ' And set some of the button's properties
    140. With oButton
    141. .DescriptionText = "Add Section"
    142. 'Tooltip text when mouse if placed over button
    143. .Caption = "AddSection"
    144. 'Text if Text in Icon is chosen
    145. .OnAction = "AddSection"
    146. 'Runs the Sub Button1() code when clicked
    147. .Style = msoButtonIcon
    148. ' Button displays as icon, not text or both
    149. .FaceId = 137
    150. '52 is my favorite pig;
    151. ' chooses icon #52 from the available Office icons
    152. End With
    153. ' Now add a button to the new toolbar
    154. Set oButton = oToolbar.Controls.Add(Type:=msoControlButton)
    155. ' And set some of the button's properties
    156. With oButton
    157. .DescriptionText = "Remove Section"
    158. 'Tooltip text when mouse if placed over button
    159. .Caption = "RemoveSection"
    160. 'Text if Text in Icon is chosen
    161. .OnAction = "RemoveSection"
    162. 'Runs the Sub Button1() code when clicked
    163. .Style = msoButtonIcon
    164. ' Button displays as icon, not text or both
    165. .FaceId = 138
    166. '52 is my favorite pig;
    167. ' chooses icon #52 from the available Office icons
    168. End With
    169. ' Now add a button to the new toolbar
    170. Set oButton = oToolbar.Controls.Add(Type:=msoControlButton)
    171. ' And set some of the button's properties
    172. With oButton
    173. .DescriptionText = "Add Ignore Slide"
    174. 'Tooltip text when mouse if placed over button
    175. .Caption = "AddIgnoreSlide"
    176. 'Text if Text in Icon is chosen
    177. .OnAction = "AddIgnoreSlide"
    178. 'Runs the Sub Button1() code when clicked
    179. .Style = msoButtonIcon
    180. ' Button displays as icon, not text or both
    181. .FaceId = 214
    182. '52 is my favorite pig;
    183. ' chooses icon #52 from the available Office icons
    184. End With
    185. ' Now add a button to the new toolbar
    186. Set oButton = oToolbar.Controls.Add(Type:=msoControlButton)
    187. ' And set some of the button's properties
    188. With oButton
    189. .DescriptionText = "Remove Ignore Slide"
    190. 'Tooltip text when mouse if placed over button
    191. .Caption = "RemoveIgnoreSlide"
    192. 'Text if Text in Icon is chosen
    193. .OnAction = "RemoveIgnoreSlide"
    194. 'Runs the Sub Button1() code when clicked
    195. .Style = msoButtonIcon
    196. ' Button displays as icon, not text or both
    197. .FaceId = 213
    198. '52 is my favorite pig;
    199. ' chooses icon #52 from the available Office icons
    200. End With
    201. ' Now add a button to the new toolbar
    202. Set oButton = oToolbar.Controls.Add(Type:=msoControlButton)
    203. ' And set some of the button's properties
    204. With oButton
    205. .DescriptionText = "Clear Structure"
    206. 'Tooltip text when mouse if placed over button
    207. .Caption = "Delete old structure"
    208. 'Text if Text in Icon is chosen
    209. .OnAction = "ClearOldStructure"
    210. 'Runs the Sub Button1() code when clicked
    211. .Style = msoButtonIcon
    212. ' Button displays as icon, not text or both
    213. .FaceId = 215
    214. '52 is my favorite pig;
    215. ' chooses icon #52 from the available Office icons
    216. End With
    217. ' Now add a button to the new toolbar
    218. Set oButton = oToolbar.Controls.Add(Type:=msoControlButton)
    219. ' And set some of the button's properties
    220. With oButton
    221. .DescriptionText = "Show Settings Dialog"
    222. 'Tooltip text when mouse if placed over button
    223. .Caption = "Show Settings"
    224. 'Text if Text in Icon is chosen
    225. .OnAction = "showSettingDialog"
    226. 'Runs the Sub Button1() code when clicked
    227. .Style = msoButtonIcon
    228. ' Button displays as icon, not text or both
    229. .FaceId = 44
    230. '52 is my favorite pig;
    231. ' chooses icon #52 from the available Office icons
    232. End With
    233. ' Now add a button to the new toolbar
    234. Set oButton = oToolbar.Controls.Add(Type:=msoControlButton)
    235. ' And set some of the button's properties
    236. With oButton
    237. .DescriptionText = "Show Info Dialog"
    238. 'Tooltip text when mouse if placed over button
    239. .Caption = "Show Info"
    240. 'Text if Text in Icon is chosen
    241. .OnAction = "showInfoDialog"
    242. 'Runs the Sub Button1() code when clicked
    243. .Style = msoButtonIcon
    244. ' Button displays as icon, not text or both
    245. .FaceId = 124
    246. '52 is my favorite pig;
    247. ' chooses icon #52 from the available Office icons
    248. End With
    249. ' Repeat the above for as many more buttons as you need to add
    250. ' Be sure to change the .OnAction property at least for each new button
    251. ' You can set the toolbar position and visibility here if you like
    252. ' By default, it'll be visible when created
    253. oToolbar.top = 150
    254. oToolbar.left = 150
    255. oToolbar.Visible = True
    256. NormalExit:
    257. Exit Sub ' so it doesn't go on to run the errorhandler code
    258. ErrorHandler:
    259. 'Just in case there is an error
    260. MsgBox Err.Number & vbCrLf & Err.Description
    261. Resume NormalExit:
    262. End Sub
    263. Sub showSettingDialog()
    264. settingsForm.Show
    265. End Sub
    266. Sub showInfoDialog()
    267. helpForm.Show
    268. End Sub
    269. Sub AddSection()
    270. On Error Resume Next
    271. Dim presentation As Object
    272. Dim s As PowerPoint.Shape
    273. presentation = Application.ActivePresentation
    274. Set s = Application.ActiveWindow.Selection.SlideRange.Shapes.AddShape(msoShapeRectangle, 10, 10, 10, 10)
    275. s.Name = "section"
    276. s.Visible = False
    277. Application.ActiveWindow.Selection.SlideRange.Comments.Add 0, 0, "", "", "Section"
    278. End Sub
    279. Sub AddIgnoreSlide()
    280. On Error Resume Next
    281. Dim presentation As Object
    282. Dim s As PowerPoint.Shape
    283. presentation = Application.ActivePresentation
    284. Application.ActiveWindow.Selection.SlideRange.NotesPage.Tags.Add "Ignore", "True"
    285. Set s = Application.ActiveWindow.Selection.SlideRange.Shapes.AddShape(msoShapeRectangle, 10, 10, 10, 10)
    286. s.Name = "ignore"
    287. s.Visible = False
    288. Application.ActiveWindow.Selection.SlideRange.Comments.Add 0, 0, "", "", "Ignore"
    289. End Sub
    290. Sub RemoveSection()
    291. On Error Resume Next
    292. Dim currentSlide As slide
    293. 'Dim currSlideNum As Integer
    294. 'currSlideNum = ActiveWindow.View.Slide.SlideIndex
    295. 'Set currentSlide = ActiveWindow.Selection.SlideRange.Item(currSlideNum)
    296. 'Set currentSlide = ActivePresentation.Slides(currSlideNum)
    297. Set currentSlide = ActivePresentation.Slides(ActiveWindow.View.slide.Name)
    298. With currentSlide
    299. .Shapes("section").Delete
    300. .Comments.Item(1).Delete
    301. End With
    302. End Sub
    303. Sub RemoveIgnoreSlide()
    304. On Error Resume Next
    305. Dim currentSlide As slide
    306. Set currentSlide = ActivePresentation.Slides(ActiveWindow.View.slide.Name)
    307. With currentSlide
    308. .Shapes("ignore").Delete
    309. .Comments.Item(1).Delete
    310. End With
    311. End Sub
    312. Sub AddDetailedProgressBar()
    313. ScreenUpdating(FindWindowHandle(Application)) = False
    314. RemoveDetailedProgressBar
    315. On Error Resume Next
    316. Dim presentation As PowerPoint.presentation
    317. Dim s As PowerPoint.Shape
    318. Set presentation = Application.ActivePresentation
    319. Dim counter As Integer: counter = 0
    320. Dim slide As slide
    321. Dim X As Integer: X = 0
    322. Dim initialTop As Integer: initialTop = 0
    323. Dim initialLeft As Integer: initialLeft = 0
    324. Dim bulletCounter As Integer: bulletCounter = 0
    325. Dim Count As Integer: Count = 0
    326. Dim sectionCounter As Integer: sectionCounter = 0
    327. Dim slidesPerSection As Integer: slidesPerSection = 0
    328. Dim numberOfSections As Integer: numberOfSections = 0
    329. Dim sectionLength As Variant: sectionLength = 0
    330. Dim mySections() As Integer
    331. Dim sectionSlides() As Integer
    332. ReDim Preserve mySections(0 To 1)
    333. ReDim Preserve sectionSlides(0 To 1)
    334. ' Determine structure of slide set
    335. With presentation
    336. For X = 1 To .Slides.Count
    337. Dim notHidden As Boolean
    338. notHidden = Not .Slides(X).SlideShowTransition.Hidden
    339. Dim notIgnored As Boolean
    340. If .Slides(X).NotesPage.Tags.Count = 0 Then
    341. notIgnored = True
    342. Else
    343. notIgnored = False
    344. End If
    345. If notHidden And notIgnored Then
    346. 'get slide numbers
    347. ReDim Preserve sectionSlides(0 To (UBound(sectionSlides) + 1))
    348. sectionSlides(counter) = .Slides(X).slideNumber
    349. counter = counter + 1
    350. If IsNull(.Slides(X).Shapes("section")) Then
    351. mySections(sectionCounter) = mySections(sectionCounter) + 1
    352. Else
    353. ReDim Preserve mySections(0 To (UBound(mySections) + 1))
    354. sectionCounter = sectionCounter + 1
    355. mySections(sectionCounter) = 1
    356. End If
    357. End If
    358. Next X
    359. End With
    360. 'load from settings
    361. Dim left As Integer: left = CInt(GetSetting(appname:="PogressBar", Section:="PosPogressBar", Key:="leftPos"))
    362. Dim top As Integer: top = presentation.PageSetup.SlideHeight - CInt(GetSetting(appname:="PogressBar", Section:="PosPogressBar", Key:="topPos"))
    363. Dim sizeOfBullet As Integer: sizeOfBullet = CInt(GetSetting(appname:="PogressBar", Section:="PosPogressBar", Key:="sizeOfBullet"))
    364. Dim spaceBetweenBullets As Integer: spaceBetweenBullets = CInt(GetSetting(appname:="PogressBar", Section:="PosPogressBar", Key:="spaceBetweenBullets"))
    365. Dim maxleft As Integer: maxleft = CInt(GetSetting(appname:="PogressBar", Section:="PosPogressBar", Key:="wraparound"))
    366. Dim wraparoundoffset As Integer: wraparoundoffset = CInt(GetSetting(appname:="PogressBar", Section:="PosPogressBar", Key:="wraparoundlimit"))
    367. Dim colorRed As Integer: colorRed = CInt(GetSetting(appname:="PogressBar", Section:="PosPogressBar", Key:="colorRed"))
    368. Dim colorYellow As Integer: colorYellow = CInt(GetSetting(appname:="PogressBar", Section:="PosPogressBar", Key:="colorYellow"))
    369. Dim colorBlue As Integer: colorBlue = CInt(GetSetting(appname:="PogressBar", Section:="PosPogressBar", Key:="colorBlue"))
    370. Dim vertical As Boolean: vertical = CBool(GetSetting(appname:="PogressBar", Section:="PosPogressBar", Key:="OptionVertical"))
    371. 'init if fields are null
    372. If IsNull(left) Then
    373. left = 20
    374. End If
    375. 'init if fields are null
    376. If IsNull(maxleft) Then
    377. left = 500
    378. End If
    379. If IsNull(top) Then
    380. top = 50
    381. End If
    382. If IsNull(sizeOfBullet) Then
    383. sizeOfBullet = 6
    384. End If
    385. If IsNull(spaceBetweenBullets) Then
    386. spaceBetweenBullets = 8
    387. End If
    388. 'init if fields are null
    389. If IsNull(wraparoundoffset) Then
    390. wraparoundoffset = 2 * sizeOfBullet
    391. End If
    392. initialLeft = left
    393. initialTop = top
    394. With presentation
    395. Dim currentSlideNumber As Integer: currentSlideNumber = 0
    396. For Each slide In .Slides
    397. 'bullet counter needed to do wrap arround
    398. bulletCounter = 0
    399. left = initialLeft
    400. top = initialTop
    401. Dim slideNumber As Integer: slideNumber = 0
    402. 'Dim notHidden As Boolean: notHidden = Slide.SlideShowTransition.Hidden = Microsoft.Office.Core.MsoTriState.msoFalse
    403. notHidden = Not slide.SlideShowTransition.Hidden
    404. 'Dim notIgnored As Boolean
    405. notIgnored = True
    406. If slide.NotesPage.Tags.Count = 0 Then
    407. notIgnored = True
    408. Else
    409. notIgnored = False
    410. End If
    411. If notHidden And notIgnored Then
    412. For Each sectionLength In mySections
    413. If vertical Then
    414. If top > maxleft Then
    415. left = left + wraparoundoffset
    416. top = initialLeft
    417. End If
    418. Else
    419. If left > maxleft Then
    420. top = top + wraparoundoffset
    421. left = initialLeft
    422. End If
    423. End If
    424. For Count = 1 To sectionLength
    425. bulletCounter = bulletCounter + 1
    426. Set s = slide.Shapes.AddShape(msoShapeOval, left, top, sizeOfBullet, sizeOfBullet)
    427. s.Name = "PB_" & CStr(slideNumber)
    428. If currentSlideNumber = slideNumber Then
    429. s.Fill.ForeColor.RGB = RGB(colorRed, colorYellow, colorBlue)
    430. s.Line.ForeColor.RGB = RGB(colorRed, colorYellow, colorBlue)
    431. Else
    432. s.Fill.ForeColor.RGB = RGB(220, 220, 220)
    433. s.Line.ForeColor.RGB = RGB(150, 150, 150)
    434. End If
    435. With s.ActionSettings(ppMouseClick)
    436. .Action = ppActionNamedSlideShow
    437. With .Hyperlink
    438. '.Address = Me.Application.ActivePresentation.FullName
    439. .SubAddress = CStr(sectionSlides(slideNumber))
    440. .Follow
    441. End With
    442. End With
    443. slideNumber = slideNumber + 1
    444. If vertical Then
    445. top = top + spaceBetweenBullets
    446. Else
    447. left = left + spaceBetweenBullets
    448. End If
    449. Next Count
    450. If vertical Then
    451. top = top + spaceBetweenBullets
    452. Else
    453. left = left + spaceBetweenBullets
    454. End If
    455. Next sectionLength
    456. 'slide.Shapes("PB").Delete()
    457. currentSlideNumber = currentSlideNumber + 1
    458. End If
    459. Next
    460. End With
    461. ScreenUpdating(FindWindowHandle(Application)) = True
    462. End Sub
    463. Sub RemoveDetailedProgressBar()
    464. Dim presentation As PowerPoint.presentation
    465. Set presentation = Application.ActivePresentation
    466. Dim X As Integer: X = 0
    467. Dim slide As slide
    468. With presentation
    469. For Each slide In .Slides
    470. For X = 0 To slide.Shapes.Count
    471. On Error Resume Next
    472. 'Debug.Print slide.Shapes.Count
    473. Debug.Print slide.Shapes(X).Name
    474. slide.Shapes("PB_" & CStr(X)).Delete
    475. Next
    476. Next
    477. End With
    478. End Sub
    479. Sub ClearOldStructure()
    480. Dim presentation As PowerPoint.presentation
    481. Set presentation = Application.ActivePresentation
    482. Dim slide As slide
    483. With presentation
    484. For Each slide In .Slides
    485. On Error Resume Next
    486. With slide
    487. .Shapes("ignore").Delete
    488. .Comments.Item(1).Delete
    489. .Shapes("section").Delete
    490. .Comments.Item(1).Delete
    491. End With
    492. For X = 0 To slide.Shapes.Count
    493. On Error Resume Next
    494. slide.Shapes("PB_" & CStr(X)).Delete
    495. Next
    496. Next
    497. End With
    498. End Sub
    499. Sub ShowFaceIDs()
    500. Dim NewToolbar As CommandBar
    501. Dim NewButton As CommandBarButton
    502. Dim i As Integer, IDStart As Integer, IDStop As Integer
    503. ' Delete existing FaceIds toolbar if it exists
    504. On Error Resume Next
    505. Application.CommandBars("FaceIds").Delete
    506. On Error GoTo 0
    507. ' Add an empty toolbar
    508. Set NewToolbar = Application.CommandBars.Add _
    509. (Name:="FaceIds", temporary:=True)
    510. NewToolbar.Visible = True
    511. ' Change the following values to see different FaceIDs
    512. IDStart = 1
    513. IDStop = 250
    514. For i = IDStart To IDStop
    515. 'Set NewButton = NewToolbar.Add(Type:=msoControlButton, Id:=2950)
    516. Set NewButton = NewToolbar.Controls.Add(Type:=msoControlButton)
    517. NewButton.FaceId = i
    518. NewButton.Caption = "FaceID = " & i
    519. Next i
    520. NewToolbar.Width = 600
    521. End Sub

    Mir ist bei Excel und Co wirklich lieber, wenn ich eine Excel-Mappe runterladen kann, wo der Fehler drin ist. Nachbauen macht, zumindest mir, keinen Spaß. :rolleyes:
    Gruß
    Peterfido

    Keine Unterstützung per PN!