macro cercaelimina collegamenti



  • macro cerca-elimina collegamenti
    di marxitpa data: 13/04/2015 16:48:41

    Le due macro seguenti permettono ... la prima di individuare i collegamenti in un foglio attivo e la seconda di eliminarli.
    E' possibile fare in modo che, una volta individuati i collegamenti con la prima, si possano scegliere quelli da eliminare?

    ... magari assemblando in un'unica macro ...
    grazie

     
    ' macro Trova collegamenti nel foglio attivo
    Sub TrovaCollegamenti()
    Dim xIper As Integer
    Dim xEst As Integer
    Dim collIper As String
    Dim collEst As String
    
    For Each Hyperlink In ActiveSheet.Hyperlinks
        xIper = xIper + 1
        If Hyperlink.Address = "" Then
        collIper = collIper & Hyperlink.SubAddress
        Else
        collIper = collIper & Hyperlink.Address
        End If
        collIper = collIper & vbCrLf
    Next
    
    For Each QueryTable In ActiveSheet.QueryTables
        xEst = xEst + 1
        collEst = collEst & QueryTable.Connection & " - " _
        & QueryTable.Destination.Address(0, 0)
        collEst = collEst & vbCrLf
    Next
    
    If xIper > 0 And xEst > 0 Then
        MsgBox "ci sono n. " & xIper & " collegamenti ipertestuali:" _
        & vbCrLf & collIper & vbCrLf & _
        "e n. " & xEst & " collegamenti esterni:" _
        & vbCrLf & collEst, vbExclamation
    ElseIf xIper > 0 And xEst = 0 Then
        MsgBox "ci sono n. " & xIper & " collegamenti ipertestuali:" _
        & vbCrLf & collIper, vbExclamation
    ElseIf xIper = 0 And xEst > 0 Then
        MsgBox "ci sono n. " & xEst & " collegamenti esterni:" _
        & vbCrLf & collEst, vbExclamation
    Else
        MsgBox "nessun collegamento trovato", vbCritical
    End If
    
    End Sub
    ' --------------------------------------------------------------------------------
    '  macro elimina collegamenti
    Public Sub EliminaHyperlinks()
    
        Dim hc As Integer
        Dim i As Integer
    
            With ActiveSheet
    
                hc = .Hyperlinks.Count
    
                    For i = 1 To hc
                        .Hyperlinks(1).Delete
                    Next i
    
            End With
    
    End Sub



  • di Luca73 data: 13/04/2015 17:03:53

    Prova un po questa l'ho buttata giù di corsa,
    per ogni hyperlink ti chiede se lo vuoi eliminare o no

     
    Sub TrovaEliminaCollegamenti()
    Dim collIper As String
    Dim Messaggio As String
    For Each Hyperlink In ActiveSheet.Hyperlinks
        If Hyperlink.Address = "" Then
            collIper = collIper & Hyperlink.SubAddress
        Else
            collIper = collIper & Hyperlink.Address
        End If
        Messaggio = MsgBox("Cancello l'Hyperlink " & collIper & "?", vbYesNo + vbQuestion, "CANCELLO?")
        If Messaggio = vbYes Then
            Hyperlink.Delete
        End If
    Next
    End Sub






  • di marxitpa data: 13/04/2015 17:19:33

    grazie Luca73 per la velocità nella risposta.
    Mi individua i collegamenti e mi chiede se eliminarli o no.
    Alla fine del ciclo però excel stranamente si riavvia ...



  • di marxitpa data: 13/04/2015 17:32:33

    forse ho individuato il problema ...
    ... non opera nelle celle bloccate ...



  • di marxitpa data: 14/04/2015 15:48:02

    Il codice suggerito e 'buttato giù di corsa' da Luca73 funziona, individua ogni hyperlink e chiede se lo vuoi eliminare o no. Ringrazio Luca73
    Chiedo ... è possibile, nell'individuare il singolo hyperlink, che si evidenzi la cella dove è presente?
    e in caso affermativo dare la possibilità di 'sospendere momentaneamente' l'esecuzione del codice e dare la possibilità di 'operare' nella cella (es. evidenziare)?