richarddawson

Board Regular
Joined
Oct 18, 2014
Messages
87
I have a need to be able to discover if there is anything on the Office Clipboard. An item count would be perfect.
I am using 64 bit - but can usually adapt 32 bit instructions.

I am reluctant to try the alternative of using the system as this would raise a whole new range of questions - though it would be easier to clear.
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Hi,
The subject of this thread intrigued me and I have done some research so in case you are still interested, you can take a look at this post where I wrote functions that use very small Active Accessibility code to determine if the office clipboard is empty or not and if so how many items there are in it.
 
Upvote 0
Thanks, Jaafar,

Unusually your code works perfectly straight out of the box! Solves my problem too!

I resort to clearing the clip board by using VBA to position the cursor on the "clear all" button and then clicking the mouse,
but I feel this is clumsy. Did you , by any chance, write a routine to clear it?

With many thanks, Richard
 
Upvote 0
Thanks, Jaafar,

I resort to clearing the clip board by using VBA to position the cursor on the "clear all" button and then clicking the mouse,
but I feel this is clumsy. Did you , by any chance, write a routine to clear it?

With many thanks, Richard

Try this simplified code : (Credit goes to E v R from http://www.helpmij.nl/forum/forumdisplay.php/5-Excel)
Code:
Option Explicit

[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=If]#If[/URL]  VBA7 Then
    Declare PtrSafe Function AccessibleChildren Lib "oleacc" (ByVal paccContainer As Office.IAccessible, ByVal iChildStart As Long, ByVal cChildren As Long, ByRef rgvarChildren As Any, ByRef pcObtained As Long) As Long
[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=Else]#Else[/URL] 
    Declare Function AccessibleChildren Lib "oleacc" (ByVal paccContainer As Office.IAccessible, ByVal iChildStart As Long, ByVal cChildren As Long, ByRef rgvarChildren As Any, ByRef pcObtained As Long) As Long
[URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=End]#End[/URL]  If

Sub ClearOfficeClipBoard()
    Dim avAcc, bClipboard As Boolean, j As Long
    
    Set avAcc = Application.CommandBars("Office Clipboard")
        bClipboard = avAcc.Visible
        If Not bClipboard Then
            avAcc.Visible = True
            DoEvents
        End If
        For j = 1 To 4
            AccessibleChildren avAcc, Choose(j, 0, 3, 0, 3), 1, avAcc, 1
        Next
        avAcc.accDoDefaultAction 2& '1& for paste
        Application.CommandBars("Office Clipboard").Visible = bClipboard
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,533
Messages
6,114,179
Members
448,554
Latest member
Gleisner2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top