XL 2010 Redimensionner une image

Boostez vos compétences Excel avec notre communauté !

Rejoignez Excel Downloads, le rendez-vous des passionnés où l'entraide fait la force. Apprenez, échangez, progressez – et tout ça gratuitement ! 👉 Inscrivez-vous maintenant !

Magic_Doctor

XLDnaute Barbatruc
Bonjour,

Le problème est le suivant :
Je clique sur un bouton et apparaissent :
- une image qui occupe une partie de l'écran
- un bouton qui, lorsque je clique dessus, commande le redimensionnement de l'image afin qu'elle occupe pratiquement tout l'écran. Si je reclique sur ce bouton, l'image reprend ses dimensions antérieures.
Je ne parviens pas à redimensionner cette image. J'ai bien essayé avec l'enregistreur de macro mais sans succès.
Comment s'y prendre ?
 
Bonjour Magic_Doctor, le forum,

Vois si ceci te convient :
VB:
Sub Image()
Dim test As Boolean
With ThisWorkbook.Names
    .Add "X", 190
    .Add "Y", 80
    .Add "W", 260
    .Add "H", 120
End With
With ActiveSheet.DrawingObjects("Bouton")
    test = .Text = "Grand"
    .Text = IIf(test, "Petit", "Grand")
End With
Application.DisplayFullScreen = test
With ActiveSheet.Shapes("Mon_Image")
    .Left = IIf(test, 0, [X])
    .Top = IIf(test, 0, [Y])
    .Width = IIf(test, Application.Width, [W])
    .Height = IIf(test, Application.Height, [H])
End With
End Sub
Bonne journée.
 

Pièces jointes

bonsoir @job75
on peut simplifier
VB:
Option Explicit

Sub Image()
    With ActiveSheet.Shapes("Mon_Image")
        Application.DisplayFullScreen = .Width = 260
        .Left = IIf(.Left = 190, 0, 190)
        .Top = IIf(.Top = 80, 0, 80)
        .Width = IIf(.Width = 260, Application.Width, 260)
        .Height = IIf(.Height = 120, Application.Height, 120)
    End With
End Sub
 
Bonsoir patricktoulon,

Je préfère cette amélioration qui mémorise les dernières position et dimensions, fichier (2) :
VB:
Sub Image()
Dim test As Boolean, im As Shape
With ActiveSheet.DrawingObjects("Bouton")
    test = .Text = "Grande"
    .Text = IIf(test, "Petite", "Grande")
End With
Set im = ActiveSheet.Shapes("Mon_Image")
If test Then
    With ThisWorkbook.Names
        .Add "X", im.Left 'mémorise la dernière position
        .Add "Y", im.Top
        .Add "W", im.Width 'mémorise les dernières dimensions
        .Add "H", im.Height
    End With
End If
Application.DisplayFullScreen = test
With im
    .Left = IIf(test, 0, [X])
    .Top = IIf(test, 0, [Y])
    .Width = IIf(test, Application.Width, [W])
    .Height = IIf(test, Application.Height, [H])
End With
End Sub
A+
 

Pièces jointes

- Navigue sans publicité
- Accède à Cléa, notre assistante IA experte Excel... et pas que...
- Profite de fonctionnalités exclusives
Ton soutien permet à Excel Downloads de rester 100% gratuit et de continuer à rassembler les passionnés d'Excel.
Je deviens Supporter XLD

Discussions similaires

Réponses
2
Affichages
571
Réponses
6
Affichages
476
Réponses
2
Affichages
2 K
Réponses
2
Affichages
537
Retour