….. continued from the last two posts…..
I am going to take a Layman guess for now that we can forget 32Bit / 64Bit issues, and that this attempt from me could be a new small coding version that will do the job from Office 2003 upwards. (It’s in the uploaded File also - Sub small_20202024_ClearOfficeClipBoard_() )
I tested it so far on quite a few computers with operating systems XP, Vista Windows 7 8.1 10 and 11 and Office versions 2003 2007 2010 2013. Unfortunately I only have one higher version Office, 2016. It works on that.
The important difference between mine and what Hans found is just this bit
Code:
' coding change for Office versions at -- Office 2016 ==
If CLng(Val(Application.Version)) < 16 Then
' --For Office versions 2003 2007 2010 2013 ----------------------------------------
For j = 1 To 4 ' J = 1 2 3 4
AccessibleChildren avAcc, Choose(j, 0, 3, 0, 3), 1, avAcc, 1
Next
avAcc.accDoDefaultAction 2& ' This seems to do the clearing It will NOT error if viewer pain is empty 1& for paste
' ----------------------------------------------------------------------------------
Else
' ==For Office versions 2016 and higher ==============================================
For j = 1 To 7 ' J = 1 2 3 4 5 6 7
AccessibleChildren avAcc, Choose(j, 0, 3, 0, 3, 0, 3, 1), 1, avAcc, 1
Next
avAcc.accDoDefaultAction 0& ' This seems to do the clearing It WILL error if viewer pain is empty
End If ' =======================================================================
So I have just a slightly changed section for Office 2013 and lower.
I would welcome
_1) any comment s, generally
as well as
_2) if anyone passing could try that coding and tell me if it worked or not and at the same time tell me their version info.,( OS and Office). That would be particularly useful for newer versions, also 64 Bit versions if anyone has them.
_3) Based on what we have seen and learnt with these more recent small codings, I wonder if anyone has any ideas on how to get the previous big coding types to work on Office 2016 upwards. I ask this because the big codings seem to be doing things a bit differently, and it could be useful to have the different coding available as an alternative, for example to try if for some reason the small ones one day did not work
Some minor observations:
(_(i) This is perhaps obvious from the discussions so far, but just to make sure and clear: The coding Hans found does not work in Offices 2013 and lower : In the loop at J = 6 I get the run time error '424' Object needed )
_(ii)
Originally Posted by
SpeakEasy post_id=319225 time=1721760469 user_id=8741
the code as written will error if there is nothing in the Office Clipboard
I can confirm that also for my coding on my Office 2016. However my coding does not error for Office versions 2013 and lower. Maybe that tells someone something, (of course for Office 2016 and higher my coding and the one Hans found are pretty well doing the same, but for Office 2013 and lower mine does it a bit differently, as seen in the snippet above)
_ (iii) I don’t see any obvious difference in how a typical Offices Clipboard viewer pain looks like across the Office versions 2003 2007 2010 2013 2016 that might explain why the coding needs to be different from Office 2016: They all look a bit different to my layman eye.
Alan
Bookmarks