Results 1 to 10 of 190

Thread: Appendix Thread 2. ( Codes for other Threads, HTML Tables, etc.)

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,521
    Rep Power
    10

    Early Binding and Later Late Binding fo data objects

    Coding in support of this post:
    http://www.excelfox.com/forum/showth...ll=1#post11018




    Code:
    Sub MSFORMS_Early_Copy_and_Later_Late_Binding_Paste()
    Rem 1 Late Binding
    Dim DtaObj As MSForms.DataObject                                         '   RefMSFORMS.JPG : https://imgur.com/8zKpyr2
     Set DtaObj = New MSForms.DataObject
    'Dim DtaObj As New MSForms.DataObject
    Rem 1 ' Arbritrary Excel range values copy
     Let Range("A1").Value = "CellA1": Let Range("A2").Value = "CellA2": Let Range("B1").Value = "CellB1": Let Range("B2").Value = "CellB2"
    Rem 2 Clipboard Data object stuff - get the long string that is held in  some clipboards
     Range("A1:B2").Copy '                                ' This seems to fill Excel, Windows and Office Clipboards http://www.eileenslounge.com/viewtopic.php?f=30&t=31849&p=246889#p246887
    ' Get some string version from some clipboard using a DataObject method
    ' Let Application.CutCopyMode = False                 ' generally speaking these two code lines will not clear the Windows Clipboards,
    ' Call ClearOffPainBouton                             ' but they do for the case of a range copy having put them in. So we can't do these here
     DtaObj.GetFromClipboard '                            ' This is filling a regisrre and possibly sometimes setting referrences that may prevent other things being done, or put them in a Queue, bit most likely to put a spanner in the works
     Let Application.CutCopyMode = False
     Call ClearOffPainBouton
    ' Range("A1:B2").Clear '                              ' This will cause us to fail .. very strange  ..  this could suggest that we are still holding a range referrence at this stage
    Dim strGet As String: Let strGet = DtaObj.GetText()
     Range("A1:B2").Clear                                 ' At this point it is fine to do this
    Rem 3 examine string
     Call WtchaGot(strIn:=strGet) '                       ' Function to see string   :     https://pastebin.com/gtLaBrf5
    '3b Do some modification of the string
     Let strGet = Replace(strGet, vbTab, "|", 1, -1, vbBinaryCompare) '  replace in the strGet ,  vbTab  ,  with "|" pipes  ,   I want all output so starting at first character   ,  -1 means replace all occurances   ,  exact match using computer exact digits
    ' Call ClearWindowsClipboard                          ' http://www.excelfox.com/forum/showthread.php/2056-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=11020&viewfull=1#post11020    clearing the windows clipboard  at this point also messes the simple reverse process from working. This makes no sense at all: Clearly clearing does not always clear things: It may do this in many occasions as one of its actions, but it can also do things which have something near to the opposite effect.
    
    Rem 4 Replace the version previously got using another DataObject method
    '4a) Simple reverse action
     DtaObj.Clear ' Without this the following 2 line simple reverse action would not work
    ' DtaObj.SetText Text:=strGet:                         ' Let strGet = DtaObj.GetText() ' - This always gets the last "addition" ...  https://stackoverflow.com/questions/25091571/strange-behavior-from-vba-dataobject-gettext-returns-what-is-currently-on-the-c/54960767#54960767
    ' DtaObj.PutInClipboard
    '4b) Later Late Binding
    Dim LaterDtaObj As Object
     Set LaterDtaObj = CreateObject("New:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}")
     'Set LaterDtaObj = CreateObject("MSForms.DataObject") '  https://bytecomb.com/copy-and-paste-in-vba/
     LaterDtaObj.SetText Text:=strGet
     LaterDtaObj.PutInClipboard
    Rem 5 ' Excel Range Paste                                ( using Worksheet.Paste method https://docs.microsoft.com/en-us/office/vba/api/excel.worksheet.paste )
     ActiveSheet.Paste Destination:=ActiveSheet.Range("A1")
    End Sub

    Code:
    ' SHimpfGlified Coding
    Sub Early_Copy_and_Later_Late_Binding_Paste()
    Rem 1 Late Binding
    Dim DtaObj As MSForms.DataObject  '   RefMSFORMS.JPG : https://imgur.com/8zKpyr2
     Set DtaObj = New MSForms.DataObject
    Rem 1 ' Arbritrary Excel range values copy
     Let Range("A1").Value = "CellA1": Let Range("A2").Value = "CellA2": Let Range("B1").Value = "CellB1": Let Range("B2").Value = "CellB2"
    Rem 2 Clipboard Data object stuff - get the long string that is held in  some clipboards
     Range("A1:B2").Copy '
     DtaObj.GetFromClipboard '
    Dim strGet As String: Let strGet = DtaObj.GetText()
     Range("A1:B2").Clear
    Rem 3 examine string
     ' Call WtchaGot(strIn:=strGet) '
    '3b Do some modification of the string
     Let strGet = Replace(strGet, vbTab, "|", 1, -1, vbBinaryCompare)
    Rem Simple reverse action. Later Late Binding
    Dim LaterDtaObj As Object
     Set LaterDtaObj = CreateObject("New:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}")
     LaterDtaObj.SetText Text:=strGet
     LaterDtaObj.PutInClipboard
    Rem 5 ' Excel Range Paste                                ( using Worksheet.Paste method https://docs.microsoft.com/en-us/office/vba/api/excel.worksheet.paste )
     ActiveSheet.Paste Destination:=ActiveSheet.Range("A1")
    End Sub
    Last edited by DocAElstein; 03-03-2019 at 09:31 PM.

Similar Threads

  1. VBA to Reply All To Latest Email Thread
    By pkearney10 in forum Outlook Help
    Replies: 11
    Last Post: 12-22-2020, 11:15 PM
  2. Appendix Thread. Diet Protokol Coding Adaptions
    By DocAElstein in forum Test Area
    Replies: 6
    Last Post: 09-05-2019, 10:45 AM
  3. Replies: 19
    Last Post: 04-20-2019, 02:38 PM
  4. Search List of my codes
    By PcMax in forum Excel Help
    Replies: 6
    Last Post: 08-03-2014, 08:38 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
  •