Page 55 of 56 FirstFirst ... 54553545556 LastLast
Results 541 to 550 of 554

Thread: Tests Copying pasting Cliipboard issues. and otes on API stuff

  1. #541
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,458
    Rep Power
    10
    mmd,,dndak

    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    https://eileenslounge.com/viewtopic.php?p=318868#p318868
    https://eileenslounge.com/viewtopic.php?p=318311#p318311
    https://eileenslounge.com/viewtopic.php?p=318302#p318302
    https://eileenslounge.com/viewtopic.php?p=317704#p317704
    https://eileenslounge.com/viewtopic.php?p=317704#p317704
    https://eileenslounge.com/viewtopic.php?p=317857#p317857
    https://eileenslounge.com/viewtopic.php?p=317541#p317541
    https://eileenslounge.com/viewtopic.php?p=317520#p317520
    https://eileenslounge.com/viewtopic.php?p=317510#p317510
    https://eileenslounge.com/viewtopic.php?p=317547#p317547
    https://eileenslounge.com/viewtopic.php?p=317573#p317573
    https://eileenslounge.com/viewtopic.php?p=317574#p317574
    https://eileenslounge.com/viewtopic.php?p=317582#p317582
    https://eileenslounge.com/viewtopic.php?p=317583#p317583
    https://eileenslounge.com/viewtopic.php?p=317605#p317605
    https://eileenslounge.com/viewtopic.php?p=316935#p316935
    https://eileenslounge.com/viewtopic.php?p=317030#p317030
    https://eileenslounge.com/viewtopic.php?p=317030#p317030
    https://eileenslounge.com/viewtopic.php?p=317014#p317014
    https://eileenslounge.com/viewtopic.php?p=316940#p316940
    https://eileenslounge.com/viewtopic.php?p=316927#p316927
    https://eileenslounge.com/viewtopic.php?p=316875#p316875
    https://eileenslounge.com/viewtopic.php?p=316704#p316704
    https://eileenslounge.com/viewtopic.php?p=316412#p316412
    https://eileenslounge.com/viewtopic.php?p=316412#p316412
    https://eileenslounge.com/viewtopic.php?p=316254#p316254
    https://eileenslounge.com/viewtopic.php?p=316046#p316046
    https://eileenslounge.com/viewtopic.php?p=317050&sid=d7e077e50e904a138c794e1f2115da95#p317050
    https://www.youtube.com/@alanelston2330
    https://www.youtube.com/watch?v=yXaYszT11CA&lc=UgxEjo0Di9-9cnl8UnZ4AaABAg.9XYLEH1OwDIA35HNIei0z-
    https://eileenslounge.com/viewtopic.php?p=316154#p316154
    https://www.youtube.com/watch?v=TW3l7PkSPD4&lc=UgwAL_Jrv7yg7WWC8x14AaABAg
    https://teylyn.com/2017/03/21/dollarsigns/#comment-191
    https://eileenslounge.com/viewtopic.php?p=317050#p317050
    https://eileenslounge.com/viewtopic.php?f=27&t=40953&p=316854#p316854
    https://www.eileenslounge.com/viewtopic.php?v=27&t=40953&p=316875#p316875
    https://eileenslounge.com/viewtopic.php?p=316057#p316057
    https://eileenslounge.com/viewtopic.php?p=315915#p315915
    https://eileenslounge.com/viewtopic.php?p=316705#p316705
    https://eileenslounge.com/viewtopic.php?p=316704#p316704
    https://eileenslounge.com/viewtopic.php?p=176255#p176255
    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    Last edited by DocAElstein; 07-27-2024 at 02:11 PM.

  2. #542
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,458
    Rep Power
    10

    bb

    xnm ccy cy
    Last edited by DocAElstein; 10-20-2024 at 11:18 PM.

  3. #543
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,458
    Rep Power
    10
    xvndvndvn
    Last edited by DocAElstein; 04-20-2024 at 01:32 AM.

  4. #544
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,458
    Rep Power
    10

    Test Post for an EileenLounge post PART 4 (In older post)

    Quote Originally Posted by rory post_id=246738 time=1550498216 user_id=83
    IIRC for Office 2013 or later, you need to use CommandBars("Office Clipboard") rather than CommandBars("Task Pane")
    Hi, Mr Rory.
    Since this Thread in 2019, I have used various variations of codings discussed here, across Office (Windows) versions 2003 2007 2010 2013 and 2016, and also over the last day or two I have done a few more experiments and reviews in the light of a more recent similar Thread: https://eileenslounge.com/viewtopic.php?f=27&t=41223.
    I am finding consistently that it appears that "Task Pane" is needed for codings to work in Office 2003, whereas so far in all cases the same codings need "Office Clipboard" for Offices 2007 2010 2013 and 2016. I strongly suspect that "Office Clipboard" is needed for newer Office versions also based on the codings that appear to work for others with the newer versions. Is it therefore a reasonable assumption that for 2003 and lower "Task Pane" is needed, whereas "Office Clipboard" for all above?
    ( Have you noticed that some much smaller codings have appeared in the meantime
    https://stackoverflow.com/questions/...46949#64946949
    * https://www.mrexcel.com/board/thread.../#post-5228633
    ( https://www.excelfox.com/forum/showt...ll=1#post17966
    https://www.excelfox.com/forum/showt...ll=1#post24879 )
    I am not sure where they originated? Possibly Jaafar Tribak * ?
    I tried to figure out what these where doing and had not a clue but I remember it causing me to have a strange dream of being in the dark in solitary confinement and trying to play a form of Squash / whack-a-mole with a piece of dried excrement, and a more recent enlightenment suggest I may not have been so far off with my thinking. )

    _.______________________________-

    By the way, in all the codings kicking around, this literal name issue plays a fairly minor role. Its needed to make sure the Offices Clipboard Viewer Pane thing is open/ showing . As an alternative we can use Let Application.DisplayClipboardWindow = True. I am not sure what the relative merits are, although I would have a tendency to go with earlier more fundamental stuff. But I don’t know what is the earlier more fundamental of the two ways here. (I noticed in 2003 sometimes the "Task Pane" brought something else up, so I also did the Let Application.DisplayClipboardWindow = True to get over that problem. It does not seem to error if the Offices Clipboard Viewer Pane thing is already open, so maybe it does no harm to include it also as a belt and braces approach)
    I suppose perhaps needing the thing open for the meat of the codings to work means the COM wrapper of accessiblies interface we are using is only for active accessiblies

    _._______________________________________-

    * @Yasser
    Hello Yasser,
    I think it could be a good and nice idea for you to do a follow up post over at mrexcel in your February 18, 2019 thread , to tell your Arab friend , Jaafar Tribak, about your more recent post here at eileenslounge .
    Jaafar Tribak tried to get you a solution back then, but did not manage it. You seem to have that solution now, ( the one Hans found for you )
    It is interesting that one of Jaafar Tribak's attempts for you, was close *
    Perhaps Jaafar Tribak might have some interesting comments.
    ( I note that back in February 2019, Jaafar said he only had Office 2013 so for that reason could not help you further, but it appears now that he has Office 2016



    _.________________________________

    ( One other very minor thing, a small oddity, while I am here, just for completeness. In the review I done of the two similar Threads over the past couple of days, I came across a strange thing. In this thread, (the one we are in now), there was a very monstrous big code offering , ( given from Yasser in a uploaded text file , and I reproduced it here with my usual modifications which usually allow _(i) the thing to work also in Office 2003, as well as _(ii) to work in German Office.)
    I can only get that to work in the only English Office versions I have, ( Office 2007). I suspect that coding would also work in at least Office 2003, but my usual modification of changing a literal text in the coding of "Clear All" to "Alle löschen" does not seem to help for that particular monster very big coding. This modification gets all the more typical earlier big Jaafar Tribak codings to work in my German Office, at least for all the Versions that they work in in English Office. )



    Alan
    Last edited by DocAElstein; 10-29-2024 at 11:35 AM.

  5. #545
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,458
    Rep Power
    10

    Test for a EileenLounge post 1 (Review of a similar older Thread, which failed to solve the problem)

    Review of a similar older Thread, which failed to solve the problem.




    Hi
    I thought it might be of general subject interest and helpful for future reference to mention that we had this exact same question from Yasser in 2019 ,
    (although it took us most of that Thread to figure out what he wanted, which was to get VBA to do something like when we manually click that Clear All Button .
    In the meantime we got a bit more insight into what The Windows Clipboard is really all about: It seems we are not strictly playing with a clipboard here, since there is only one, and that thing often referred to as the Office Clipboard aint really part of the The Windows Clipboard : What we are doing here is messing with something that makes its own limited copies of things last set to go on The Windows Clipboard , (in many cases, especially in Excel, those things never get there, ( there in the real clipboard that is) until a Paste. )
    We are messing with something that could also be described as a specific viewer of the phenomena that is The Windows Clipboard
    Also if you have multiple versions of Office open, they will all make their own independent copy of what is sent or set to be sent to the windows clipboard, but all our coding attempts so far will just clear stuff in the version its running in. That last bit is perhaps an important point that might be worth saying again a bit differently: Say I have Excel open from Office 2003, and I have word open from Office 2007. I then go somewhere, (anywhere, does not have to be anywhere in particular other than in Windows ), and I copy a word, Alan. That now appears in two list, one in each of the open Office versions: https://i.postimg.cc/nrhXLb56/A-Clip...ce-version.jpg
    But if I use just one of the two Clear All Buttons, then it only is cleared from that list. So that is telling us again that each of the two things is monitoring and making its own copy of what is going or set to be going to The Windows Clipboard
    (Some quirky contradiction like things do exist however. For example after using either Clear All button in one of the Offices, you will then no longer be able to do a simple windows Paste operation, even if things were copied from , and are still showing in the list in the other Office. So somehow either button does have the side effect of clearing the windows clipboard)

    So there is no single Office Clipboard in the way that there is a single windows clipboard.

    I am not trying to be annoyingly pedantic, - I just think it helps to understand things a bit better, which might lead to better and more interesting and clear solutions . Maybe calling it an Office’s Clipboard monitor might be better.
    A confusing quirk is that messing with it might effect the thing its monitoring. Maybe a bit like a old analogue pressure meter measuring some very high pressure large gas tank, and because of some badly designed leaking spaghetti dependency chains, if you mess with the monitor you might cause the tank to explode!

    Anyways, manipulating any Office’s Clipboard monitor thing in any direct way with VBA I have yet to see done.
    Smarter people have told me that third party software that tries to claim to be some clipboard monitor or other are a bit iffy.
    I think throughout we are concentrating here on just getting that button clicked, at some higher accessible interface level.
    _._________

    Back in 2019 we had a few of the mysterious API codings offered, big ones, most of which I think seemed to come from an Arab guy, who is an Author of a lot of these API thingies, Jaafar Tribak. I fiddled around, admittedly blindly, and got a version to work across Office versions 2003 2007 2010, (which was all I had at the time). It’s still was mostly Jaafar Tribak’s big coding and I was/am no the wiser how it works.
    In the light of this Thread, and also just re reading all the previous stuff, I did some minor changes/ updates, and this is probably "my" latest attempt – its still mostly from the mysterious big versions from Jaafar Tribak, which seemed to have been the standard used for many years. )


    We hit a brick wall back then, in 2019, as we could not get it working in Office 2016. So Yasser went off to mrexcel.com and got some interesting info from Jaafar Tribak , who tried but failed still to get it working in Office 2016. (Back then he only had Office versions 2007 2010 and 2013)
    (That mrexcel thread has got a bit messed up by a forum software update, so I tried to make a repaired summarized copy of it pulling out the important bits here )

    Back in 2019, the persistent error ( In Office 2016 ) with "my" coding and a few of the bigger codings offered by Jaafar Tribak at mrexcel was "Object doesn't support this property or method 'Error 438' " at the line
    Call oIA.accDoDefaultAction(vKid).
    For all previous Office version, that code line did not error, and that is the code line in the previous big codings that does the clearing, that is to say does the same as manually clicking that Clear All button in the Office’s Clipboard viewer, ( which incidentally must be open for any of the codings so far to work. I noticed on my recent review that it does not always get opened as it should by the previous codings, and I added a small mod that seems to overcome that problem)

    The only reason for this Office 2016 problem at the time that Jaafar Tribak could think of was that the hierarchy of the accessible buttons in the office clipboard had changed for Office 2016. My thinking was that something quirky was going on as we weren’t getting at any kid from the relevant interface out of the COM wrapper that should have that interface of the active accessibles…… :innocent:
    _.____________


    In the meantime I have got some 2013 Office versions and one 2016 versions, so I thought I would
    _ a) take a re look at the previous Threads
    and
    _b) a look at this recent one( the one I am writing in now) …..


    ….. maybe in the next post……
    Last edited by DocAElstein; 10-29-2024 at 11:36 AM.

  6. #546
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,458
    Rep Power
    10

    Test Post for an EileenLounge post PART 2

    Continued from last post…..

    _a) I confirmed all the previous findings, which was that the codings from 2019 were OK for Office up to and including 2013 and then the mentioned problem was also what I got in my Office 2016
    https://www.excelfox.com/forum/showt...ge11#post17966
    https://www.excelfox.com/forum/showt...ge11#post17968
    https://www.excelfox.com/forum/showt...ge11#post17969


    _._________________________________

    Now _b ), some comments and interesting findings as a result of this recent Thread, the one I am in now

    So back in early 2019 we were all stuck, even that Arab guru, Jaafar Tribak

    Now, this is the interesting thing, consider from back then in 2019, one of Jaafar Tribak’s / ("my" version of his) failed ( failed in Office 2016 ) attempts, ( and I will call this and similar looking ones from now on the more recent appearing small coding to distinguish it from the big ones that we had all back then been looking at and which had become the standard one used by many people for a long time)

    ( Note also, that back then, we all seem to have all missed the fact that this small one does actually work in Offices 2003, 2007, 2010, 2013. So we had an alternative coding to the big ones most people had been using, but we all missed that, because at the time, we were concentrating on getting something to work in Office 2016 )

    This is that smaller coding that we missed, and it would have been / (would be still for office 2013 and lower) an alternative to the previously widely used bigger type of codings. (The version here has a few simple modifications from me, just to help in the following comparisons and discussions)
    Code:
     Option Explicit
        #If 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
        #Else
         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
        #End If
    
    Sub small_2019_ClearOfficeClipBoard()  ' Slightly modified attempt of Jaafar Tribak from 2019 to  do the  Clear All  button   https://www.mrexcel.com/board/threads/reset-clear-clipboard.1087948/#post-5228633     https://www.excelfox.com/forum/showthread.php/2824-Tests-Copying-pasting-Cliipboard-issues/page11#post17966
    Dim avAcc, bClipboard As Boolean, j As Long
    Dim MyPain As String
        If CLng(Val(Application.Version)) <= 11 Then  '       Case 11: "Excel 2003" Windows  "Excel 2004"
         Let MyPain = "Task Pane"
        Else
         Let MyPain = "Office Clipboard"
        End If
    Set avAcc = Application.CommandBars(MyPain)   '
    Let bClipboard = avAcc.Visible
        If Not bClipboard Then
         Let avAcc.Visible = True
         DoEvents
        End If
        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                     1& for paste
    Let Application.CommandBars(MyPain).Visible = bClipboard         '
    End Sub
    You can see straight away that it has strong similarity to what Hans found at stack overflow.
    Having read through that stack overflow Thread a few times, I am not totally sure if the people providing the seemingly working answers totally understood what was going on as there seems to be some inconstancy and confusion in their explanations to things such as VBA7 , Win32, Win64 issues.
    I certainly don’t claim to know better, but consider these two things:
    Mike’s enlightenment ,
    and
    what Jaafar Tribak said back in 2019 when he couldn’t get that small 2019 code ( like the one I gave above) to work in Office 2016 ….. I guess the reason for the code not working in office 2016 is that the hierarchy of the accessible buttons in the office clipboard has changed. ….

    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 from me that will do the job from Office 2003 upwards.

    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.
    ( If it's any help here, the macro http://<span style="font-family: Cou...()</span> here, will give some info of your versions in the Immediate window, (although note:
    ___ Application.OperatingSystem can give quirky answers in windows 11 , so the operating system result may be wrong for if you have Windows 11
    ___ I don’t know if that macro gets it correct in Office versions 2016, 2019,2021, 2024 or 365, since I don’t have them versions to check. My guess is that it might be a bit iffy for 2016 2019,2024 or 365
    . )
    _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 codings 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
    Last edited by DocAElstein; 10-28-2024 at 02:49 PM.

  7. #547
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,458
    Rep Power
    10
    ….. 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 already  Cleared                  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 already  Cleared
        End If ' =======================================================================
    So I have just a slightly changed section for Office 2013 and lower.

    I would welcome
    _1) any comments, 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)
    Quote 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
    Last edited by DocAElstein; 10-29-2024 at 11:40 AM. Reason: Test Post for an EileenLounge post PART 3

  8. #548
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,458
    Rep Power
    10
    Later
    A Folk, A Forum, A Fuhrer ….

  9. #549
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,458
    Rep Power
    10
    A monster big one, I missed, which I expect is a version of the more typical big ones, … that might have been what Rory meant in one of his characteristic quick short answers , those ones which are not always clear what he is talking about or to what he is referring to ……
    He said
    Quote Originally Posted by rory post_id=246738 time=1550498216 user_id=83
    ..You can also reduce the code (courtesy of Jaafar Tribak) .......
    , and then he went on to give a more typical big one such as my version of a big one here https://www.excelfox.com/forum/showt...ge56#post24317


    Code:
    Option Explicit
    
    Declare Function AccessibleObjectFromWindow Lib "oleacc" ( _
     ByVal hWnd As Long, ByVal dwId As Long, _
     riid As tGUID, ppvObject As Object) As Long
    
    Declare Function AccessibleChildren Lib "oleacc" _
     (ByVal paccContainer As IAccessible, ByVal iChildStart As Long, _
     ByVal cChildren As Long, rgvarChildren As Variant, _
     pcObtained As Long) As Long
    
    Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _
     ByVal lpClassName As String, _
     ByVal lpWindowName As String) As Long
    
    Declare Function GetParent Lib "user32" (ByVal hWnd As Long) As Long
    
    Declare Function EnumChildWindows Lib "user32" (ByVal hwndParent _
     As Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
    
    Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hWnd As Long, _
     ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
    
    Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, _
     ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
    
    Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, _
     ByVal hWnd2 As Long, ByVal lpClass As String, ByVal lpCaption As String) As Long
    
    Const CHILDID_SELF = 0&
    Const ROLE_PUSHBUTTON = &H2B&
    Const WM_GETTEXT = &HD
    
    Type tGUID
     lData1 As Long
     nData2 As Integer
     nData3 As Integer
     abytData4(0 To 7) As Byte
    End Type
    
    Type AccObject
     objIA As IAccessible
     lngChild As Long
    End Type
    
    
    Dim lngChild As Long
    Dim strClass As String
    Dim strCaption As String
    'Using Active Accessibility to clear Office clipboard
    'Assumption:
    'this is running within Word or Excel as a macro, thus the global Application object is available
    Sub ClearOfficeClipboard()
     Static accButton As AccObject
     If accButton.objIA Is Nothing Then '-----
     Dim fShown As Boolean, FeelMyPain As String:
     If CLng(Val(Application.Version)) <= 11 Then '  Case 11: "Excel 2003" Windows "Excel 2004" mac
     Let FeelMyPain = "Task Pane"
     Else
     Let FeelMyPain = "Office Clipboard"
     End If
     fShown = CommandBars(FeelMyPain).Visible ' False will mean the viewer pain is not open
     If Not (fShown) Then
     CommandBars(FeelMyPain).Enabled = True
     CommandBars(FeelMyPain).Visible = True
     End If
     Let accButton = FindAccessibleChildInWindow(GetOfficeClipboardHwnd(Application), "Clear All", ROLE_PUSHBUTTON) ' For English Office
     If accButton.objIA Is Nothing Then Let accButton = FindAccessibleChildInWindow(GetOfficeClipboardHwnd(Application), "Alle löschen", ROLE_PUSHBUTTON) ' For German Office - strangely this does not appear to help in this particular coding
     End If '----------------------------------
     If accButton.objIA Is Nothing Then
     MsgBox "Unable to locate the ""Clear All"" button!"
     Else
     accButton.objIA.accDoDefaultAction accButton.lngChild ' This appears to do the clearing, but note it sets off all the other functions
     End If
    End Sub
    ' Works 2007 english
    ' Not work 2003, 2013, 2010 2017 German
    
    'Retrieve window class name
    Function GetWndClass(ByVal hWnd As Long) As String
     Dim buf As String
     Dim retval As Long
     
     buf = Space(256)
     retval = GetClassName(hWnd, buf, 255)
     GetWndClass = Left(buf, retval)
    End Function
    
    'Retrieve window title
    Function GetWndText(ByVal hWnd As Long) As String
     Dim buf As String
     Dim retval As Long
     
     buf = Space(256)
     retval = SendMessage(hWnd, WM_GETTEXT, 255, buf)
     GetWndText = Left(buf, InStr(1, buf, Chr(0)) - 1)
    End Function
    
    'The call back function used by EnumChildWindows
    Function EnumChildWndProc(ByVal hChild As Long, ByVal lParam As Long) As Long
     Dim found As Boolean
     
     EnumChildWndProc = -1
     If strClass > "" And strCaption > "" Then
     found = StrComp(GetWndClass(hChild), strClass, vbTextCompare) = 0 And _
     StrComp(GetWndText(hChild), strCaption, vbTextCompare) = 0
     ElseIf strClass > "" Then
     found = (StrComp(GetWndClass(hChild), strClass, vbTextCompare) = 0)
     ElseIf strCaption > "" Then
     found = (StrComp(GetWndText(hChild), strCaption, vbTextCompare) = 0)
     Else
     found = True
     End If
    
     If found Then
     lngChild = hChild
     EnumChildWndProc = 0
     Else
     EnumChildWndProc = -1
     End If
    End Function
    
    'Find the window handle of a child window based on its class and titie
    Function FindChildWindow(ByVal hParent As Long, Optional cls As String = "", Optional title As String = "") As Long
     lngChild = 0
     strClass = cls
     strCaption = title
     EnumChildWindows hParent, AddressOf EnumChildWndProc, 0
     FindChildWindow = lngChild
    End Function
    
    'Retrieve the IAccessible interface from a window handle
    'Reference:Jean Ross,Chapter 17: Accessibility in Visual Basic,Advanced Microsoft Visual Basic 6.0, 2nd Edition
    Function IAccessibleFromHwnd(hWnd As Long) As IAccessible
     Dim oIA As IAccessible
     Dim tg As tGUID
     Dim lReturn As Long
    
     ' Define the GUID for the IAccessible object
     ' {618736E0-3C3D-11CF-810C-00AA00389B71}
    
     With tg
     .lData1 = &H618736E0
     .nData2 = &H3C3D
     .nData3 = &H11CF
     .abytData4(0) = &H81
     .abytData4(1) = &HC
     .abytData4(2) = &H0
     .abytData4(3) = &HAA
     .abytData4(4) = &H0
     .abytData4(5) = &H38
     .abytData4(6) = &H9B
     .abytData4(7) = &H71
     End With
     ' Retrieve the IAccessible object for the form
     lReturn = AccessibleObjectFromWindow(hWnd, 0, tg, oIA)
     Set IAccessibleFromHwnd = oIA
    End Function
    
    'Recursively looking for a child with specified accName and accRole in the accessibility tree
    Function FindAccessibleChild(oParent As IAccessible, strName As String, lngRole As Long) As AccObject
     Dim lHowMany As Long
     Dim avKids() As Variant
     Dim lGotHowMany As Long, i As Integer
     Dim oChild As IAccessible
     FindAccessibleChild.lngChild = CHILDID_SELF
     If oParent.accChildCount = 0 Then
     Set FindAccessibleChild.objIA = Nothing
     Exit Function
     End If
     lHowMany = oParent.accChildCount
     ReDim avKids(lHowMany - 1) As Variant
     lGotHowMany = 0
     If AccessibleChildren(oParent, 0, lHowMany, avKids(0), lGotHowMany) <> 0 Then
     MsgBox "Error retrieving accessible children!"
     Set FindAccessibleChild.objIA = Nothing
     Exit Function
     End If
    
     'To do: the approach described in http://msdn.microsoft.com/msdnmag/issues/0400/aaccess/default.aspx
     ' are probably better and more reliable
     On Error Resume Next
     For i = 0 To lGotHowMany - 1
     If IsObject(avKids(i)) Then
     If StrComp(avKids(i).accName, strName) = 0 And avKids(i).accRole = lngRole Then
     Set FindAccessibleChild.objIA = avKids(i)
     Exit For
     Else
     Set oChild = avKids(i)
     FindAccessibleChild = FindAccessibleChild(oChild, strName, lngRole)
     If Not FindAccessibleChild.objIA Is Nothing Then
     Exit For
     End If
     End If
     Else
     If StrComp(oParent.accName(avKids(i)), strName) = 0 And oParent.accRole(avKids(i)) = lngRole Then
     Set FindAccessibleChild.objIA = oParent
     FindAccessibleChild.lngChild = avKids(i)
     Exit For
     End If
     End If
     Next i
    End Function
    
    Function FindAccessibleChildInWindow(hwndParent As Long, strName As String, lngRole As Long) As AccObject
     Dim oParent As IAccessible
     Set oParent = IAccessibleFromHwnd(hwndParent)
     If oParent Is Nothing Then
     Set FindAccessibleChildInWindow.objIA = Nothing
     Else
     FindAccessibleChildInWindow = FindAccessibleChild(oParent, strName, lngRole)
     End If
    End Function
    
    'Retrieve the window handle of the task pane
    Function GetOfficeTaskPaneHwnd(app As Object) As Long
     GetOfficeTaskPaneHwnd = FindChildWindow(app.hWnd, _
     "MsoCommandBar", Application.CommandBars("Task Pane").NameLocal)
    End Function
    
    'Retrieve the window handle of the clipboard child window inside task pane
    'The window title of the clipboard window seems to be language independent,
    'making it a better start point to searching our UI element than the task pane window
    Function GetOfficeClipboardHwnd(app As Object) As Long
     GetOfficeClipboardHwnd = FindChildWindow(app.hWnd, , "Collect and Paste 2.0")
    End Function
    Last edited by DocAElstein; 10-29-2024 at 02:16 AM.

  10. #550
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,458
    Rep Power
    10
    -

    Spare post for later related to these current posts

    https://www.excelfox.com/forum/showt...ll=1#post24317
    .

    https://www.excelfox.com/forum/showt...-issues/page56
    https://www.excelfox.com/forum/showthread.php/2824-Tests-Copying-pasting-Cliipboard-issues/page56
    https://www.excelfox.com/forum/showt...ge56#post24317
    https://www.excelfox.com/forum/showthread.php/2824-Tests-Copying-pasting-Cliipboard-issues/page56#post24317
    https://www.excelfox.com/forum/showt...ll=1#post24317
    https://www.excelfox.com/forum/showthread.php/2824-Tests-Copying-pasting-Cliipboard-issues?p=24317&viewfull=1#post24317 [/size]



    . .












































    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    https://eileenslounge.com/viewtopic.php?p=320960#p320960
    https://eileenslounge.com/viewtopic.php?p=320957#p3209573
    https://eileenslounge.com/viewtopic.php?p=318868#p318868
    https://eileenslounge.com/viewtopic.php?p=318311#p318311
    https://eileenslounge.com/viewtopic.php?p=318302#p318302
    https://eileenslounge.com/viewtopic.php?p=317704#p317704
    https://eileenslounge.com/viewtopic.php?p=317704#p317704
    https://eileenslounge.com/viewtopic.php?p=317857#p317857
    https://eileenslounge.com/viewtopic.php?p=317541#p317541
    https://eileenslounge.com/viewtopic.php?p=317520#p317520
    https://eileenslounge.com/viewtopic.php?p=317510#p317510
    https://eileenslounge.com/viewtopic.php?p=317547#p317547
    https://eileenslounge.com/viewtopic.php?p=317573#p317573
    https://eileenslounge.com/viewtopic.php?p=317574#p317574
    https://eileenslounge.com/viewtopic.php?p=317582#p317582
    https://eileenslounge.com/viewtopic.php?p=317583#p317583
    https://eileenslounge.com/viewtopic.php?p=317605#p317605
    https://eileenslounge.com/viewtopic.php?p=316935#p316935
    https://eileenslounge.com/viewtopic.php?p=317030#p317030
    https://eileenslounge.com/viewtopic.php?p=317030#p317030
    https://eileenslounge.com/viewtopic.php?p=317014#p317014
    https://eileenslounge.com/viewtopic.php?p=316940#p316940
    https://eileenslounge.com/viewtopic.php?p=316927#p316927
    https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
    Last edited by DocAElstein; 10-07-2024 at 02:26 PM.

Similar Threads

  1. Replies: 114
    Last Post: 03-04-2024, 02:39 PM
  2. Replies: 42
    Last Post: 05-29-2023, 01:19 PM
  3. Replies: 11
    Last Post: 10-13-2013, 10:53 PM
  4. Replies: 7
    Last Post: 08-28-2013, 12:57 AM
  5. Declaring API Functions In 64 Bit
    By marreco in forum Excel Help
    Replies: 2
    Last Post: 02-11-2013, 03:18 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •