Hello
I have a UserForm that runs from Powerpoint that updates the links from Excel (when the files are shared).
This UserForm has two ComboBox. One for what part of the path i want to replace and the other for the replacement string.

I am trying to feed a subrutine that start with the click of a commandButton and needs the values selected from the ComboBox.

The problem is that i dont know if the subrutine takes the values correctly. Or when i close the UserForm the changes reverse themselves.

When I run the subrutine from a Macro not a Userform it works just fine.

Thank you for any advice!

Best


Public Sub CommandButton1_Click()
Dim oSl As Slide
    Dim oHl As Hyperlink
    Dim sSearchFor As String
    Dim sReplaceWith As String
    Dim oSh As Shape
    
    sSearchFor = UserForm1.ComboBox1.Value
    If sSearchFor = "" Then
        Exit Sub
    End If

    sReplaceWith = UserForm1.ComboBox2.Value
    If sReplaceWith = "" Then
       Exit Sub
    End If

    On Error Resume Next

    For Each oSl In ActivePresentation.Slides

        For Each oHl In oSl.Hyperlinks
            oHl.Address = Replace(oHl.Address, sSearchFor, sReplaceWith)
            oHl.SubAddress = Replace(oHl.SubAddress, sSearchFor, sReplaceWith)
        Next    ' hyperlink

        ' and thanks to several astute user suggestions, let's fix OLE links
        ' and movie/sound linkes too
        For Each oSh In oSl.Shapes
           If oSh.Type = msoLinkedOLEObject _
            Or oSh.Type = msoChart Then
              oSh.LinkFormat.SourceFullName = _
                   Replace(oSh.LinkFormat.SourceFullName, _
                   sSearchFor, sReplaceWith)
           End If
       Next

    Next    ' slide
End Sub


Public Sub UserForm_Initialize()

With ComboBox1
        .AddItem ("C:\")
        .AddItem ("D:\")
End With

With ComboBox2
        .AddItem ("C:\")
        .AddItem ("D:\")
End With

End Sub