Vider le presse papier

CelluleVide

XLDnaute Occasionnel
Bonjour a tous,
J'ai une question simple: dans ma macro je copie une colonne puis je fais un collage spécial valeur et je m'arrete là.
Seulement ma colonne continue de "clignoter" (le copier est tjs actif)
Comment faire pour arreter cela? ( sachant que une fois la macro finie si je fais une autre action ou un echap, ça s'arrete)

A+
 

JCGL

XLDnaute Barbatruc
Re : Vider le presse papier

Bonjour à tous,

Roland : tant que nous saurons pas de quel ClipBoard il s'agit tout est possible...

Pour le fun et sur des codes de PMO2 :

S'il s'agit de du CB de Win :

Code:
Sub ClearWindowsClipboard()
[IV65536].Copy   'pseudo copie - écrasement du contenu du presse-papiers
Application.CutCopyMode = False
End Sub
S'il s'agit d'Office :

Code:
Option Explicit ' PMO2 sur XLD

'/// API ///
Private Declare Function FindWindowEx& Lib "user32.dll" _
  Alias "FindWindowExA" (ByVal hWnd1 As Long, _
  ByVal hWnd2 As Long, ByVal lpsz1 As String, _
  ByVal lpsz2 As String)
Private Declare Function PostMessage& Lib "user32.dll" _
  Alias "PostMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, _
  ByVal wParam As Long, ByVal lParam As Long)
'/// Messages Window ///
Const WM_LBUTTONDOWN As Long = &H201&
Const WM_LBUTTONUP As Long = &H202&

Sub ClearOfficeClipboard()
Dim CB As CommandBar
Dim Etat As Boolean
Dim hExcel2&
Dim hWindow&
Dim hParent&
Dim hClip&
Dim coord&
On Error GoTo Erreur
Application.ScreenUpdating = False
Set CB = Application.CommandBars("Task Pane")
With CB
  .Position = msoBarRight
  Etat = .Visible
End With
  If Not Etat Then Application.CommandBars(1).Controls(2).Controls(5).Execute
  hExcel2 = FindWindowEx(Application.hWnd, hExcel2, "EXCEL2", vbNullString)
  If hExcel2 = 0 Then Exit Sub
  hWindow = FindWindowEx(hExcel2, hWindow, "MsoCommandBar", CB.NameLocal)
  If hWindow Then
    hParent = hWindow
    hWindow = 0
    hWindow = FindWindowEx(hParent, hWindow, "MsoWorkPane", vbNullString)
    If hWindow Then
      hParent = hWindow
      hWindow = 0
      hClip = FindWindowEx(hParent, hWindow, "bosa_sdm_XL9", vbNullString)
    End If
  End If
If hClip > 0 Then
  coord& = 25 * 65536 + 125
  Call PostMessage(hClip, WM_LBUTTONDOWN, 0&, coord&)
  Call PostMessage(hClip, WM_LBUTTONUP, 0&, coord&)
End If
If Not Etat Then CB.Visible = False
Erreur:
Application.ScreenUpdating = True
End Sub
A+ à tous
 

Roland_M

XLDnaute Barbatruc
Re : Vider le presse papier

re

tout à fais d'accord JCGL
personnellement je pratique aussi ainsi pour (win)
Select une cellule vide pour copy et Application.CutCopyMode = False

mais il me semblait qu'il voulait libérer la sélection de Copy sur sur feuille !?
alors > Application.CutCopyMode < lui convient

EDIT:
quand au code pour Office, Merci ! je ne l'avais pas !
 

JCGL

XLDnaute Barbatruc
Re : Vider le presse papier

Bonjour à tous,
Salut Hasco :):),
Salut Roland:),

Mon cher Ges même du bout des doigts, toujours un plaisir de te croiser...
Roland : Il faut remercier PMO2... Patrick MORAND... de mémoire...

A++ Ges
A+ Roland
A+ à tous

Edition : Même si mon avatar apparait sur le GO, les codes sont de PMO2...
 

Pièces jointes

  • Nettoyer Presse-Papiers.zip
    10.4 KB · Affichages: 79
Dernière édition:

Discussions similaires

Statistiques des forums

Discussions
312 570
Messages
2 089 768
Membres
104 271
dernier inscrit
acuponctus