IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Macros et VBA Excel Discussion :

selection hyperlinks() follow [XL-2010]


Sujet :

Macros et VBA Excel

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Profil pro
    Inscrit en
    Octobre 2011
    Messages
    128
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2011
    Messages : 128
    Par défaut selection hyperlinks() follow
    Bonjour à tous,

    J'ai un souci avec une macro réalisée avec l'enregistreur.
    ça plante au niveau du selection.hyperlinks().follow

    Quelqu'un pourrait-il m'aiguiller?

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    Sub BPA()
     
    Dim R As Range
    Dim Rlig As Integer
     
     
      On Error Resume Next
       Set R = Application.InputBox("Sélectionnez une plage !", "Sélection de cellules", Type:=8)
      On Error GoTo 0
       If Not R Is Nothing Then
     
       selection.Hyperlinks(R.Value).Follow NewWindow:=False, AddHistory:=True
    'ici j'ai une erreur 91 : variable objet ou bloc with non défini
        Sheets("Devis").Select
        Sheets("Devis").Copy After:=Sheets(1)
        Sheets("Devis (2)").Select
        Sheets("Devis (2)").Name = "BpA"
        Range("J7:M9").Select
     
        With selection
            .HorizontalAlignment = xlCenter
            .VerticalAlignment = xlCenter
            .WrapText = False
            .Orientation = 0
            .AddIndent = False
            .IndentLevel = 0
            .ShrinkToFit = True
            .ReadingOrder = xlContext
            .MergeCells = False
        End With
     
        selection.Merge
        Range("J10:M12").Select
     
        With selection.Font
            .Color = -16776961
            .TintAndShade = 0
        End With
     
       Rlig = R.Row
     
        ActiveCell.FormulaR1C1 = "Bon pour Accord"
        Range("J7:M9").Select
        ActiveCell.FormulaR1C1 = ThisWorkbook.Worksheets("CC2012").Cell(Rlig, 7).Value
        Range("J7:M9").Select
        selection.Borders(xlDiagonalDown).LineStyle = xlNone
        selection.Borders(xlDiagonalUp).LineStyle = xlNone
        selection.Borders(xlEdgeLeft).LineStyle = xlNone
        selection.Borders(xlEdgeTop).LineStyle = xlNone
        selection.Borders(xlEdgeBottom).LineStyle = xlNone
        selection.Borders(xlEdgeRight).LineStyle = xlNone
        selection.Borders(xlInsideVertical).LineStyle = xlNone
        selection.Borders(xlInsideHorizontal).LineStyle = xlNone
        Range("J7:M12").Select
        Range("J10").Activate
        selection.Borders(xlDiagonalDown).LineStyle = xlNone
        selection.Borders(xlDiagonalUp).LineStyle = xlNone
        With selection.Borders(xlEdgeLeft)
            .LineStyle = xlContinuous
            .ColorIndex = 0
            .TintAndShade = 0
            .Weight = xlMedium
        End With
        With selection.Borders(xlEdgeTop)
            .LineStyle = xlContinuous
            .ColorIndex = 0
            .TintAndShade = 0
            .Weight = xlMedium
        End With
        With selection.Borders(xlEdgeBottom)
            .LineStyle = xlContinuous
            .ColorIndex = 0
            .TintAndShade = 0
            .Weight = xlMedium
        End With
        With selection.Borders(xlEdgeRight)
            .LineStyle = xlContinuous
            .ColorIndex = 0
            .TintAndShade = 0
            .Weight = xlMedium
        End With
        selection.Borders(xlInsideVertical).LineStyle = xlNone
        selection.Borders(xlInsideHorizontal).LineStyle = xlNone
        Range("J10:M12").Select
        selection.Borders(xlDiagonalDown).LineStyle = xlNone
        selection.Borders(xlDiagonalUp).LineStyle = xlNone
        With selection.Borders(xlEdgeLeft)
            .LineStyle = xlContinuous
            .ColorIndex = 0
            .TintAndShade = 0
            .Weight = xlMedium
        End With
        With selection.Borders(xlEdgeTop)
            .LineStyle = xlContinuous
            .ColorIndex = 0
            .TintAndShade = 0
            .Weight = xlMedium
        End With
        With selection.Borders(xlEdgeBottom)
            .LineStyle = xlContinuous
            .ColorIndex = 0
            .TintAndShade = 0
            .Weight = xlMedium
        End With
        With selection.Borders(xlEdgeRight)
            .LineStyle = xlContinuous
            .ColorIndex = 0
            .TintAndShade = 0
            .Weight = xlMedium
        End With
        selection.Borders(xlInsideVertical).LineStyle = xlNone
        selection.Borders(xlInsideHorizontal).LineStyle = xlNone
        Range("L39").Select
        ActiveWorkbook.Save
        ActiveWindow.Close
     
        Else
          MsgBox "Aucune plage sélectionnée", vbCritical
        End If
    End Sub
    Merci d'avance

  2. #2
    Membre Expert
    Homme Profil pro
    Inscrit en
    Décembre 2011
    Messages
    1 186
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Décembre 2011
    Messages : 1 186
    Par défaut
    Bonsoir,

    Je pense que ce que tu veux faire en ligne 12, c'est suivre le lien se trouvant dans
    la cellule sélectionnée.

    Dans ce cas remplace la ligne 12
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    selection.Hyperlinks(R.Value).Follow NewWindow:=False, AddHistory:=True
    par
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    R.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
    Rmq : Comme tout code généré par l'enregistreur, de nombreux Select peuvent être remplacé par,
    le range qui est sélectionné.

  3. #3
    Membre confirmé
    Profil pro
    Inscrit en
    Octobre 2011
    Messages
    128
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2011
    Messages : 128
    Par défaut
    merci beaucoup Blue monkey

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Multi-selection dans une ComboBox ?
    Par Moloko dans le forum MFC
    Réponses: 5
    Dernier message: 07/07/2021, 17h26
  2. [VBA-E] Follow Hyperlink récalcitrant
    Par clarisse dans le forum Macros et VBA Excel
    Réponses: 1
    Dernier message: 13/02/2007, 13h22
  3. [VB6] [Crystal] Selection enregistrement
    Par littlecow dans le forum VB 6 et antérieur
    Réponses: 3
    Dernier message: 11/01/2005, 13h08
  4. TEdit : selection du texte et autre fonction
    Par Odulo dans le forum Composants VCL
    Réponses: 5
    Dernier message: 01/08/2002, 14h27
  5. faire un selection dans une image aves les APIs
    Par merahyazid dans le forum C++Builder
    Réponses: 3
    Dernier message: 30/04/2002, 10h44

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo