-
1 Attachment(s)
Additional notes for this thread post ( What’s Chris up to) ) here:
https://eileenslounge.com/viewtopic....307833#p307833
curious wrote: ↑26 May 2023, 01:53
Rather than have multiple clipboard entries pasted all together, is there a way to have them on separate lines? Perhaps a macro? Thank you
Chris wrote: A great deal depends on how you define "clipboard' and "multiple clipboard entries", as well as whether your existing code loads the clipboard or not.
The macro "Curious" takes existing contents of the clipboard and parses the contents into sentences, allocating a separate paragraph ("line") to each sentence.
Additional notes for this thread post ( What’s Chris up to) here:
https://eileenslounge.com/viewtopic....307833#p307833
curious wrote: ↑26 May 2023, 01:53
Rather than have multiple clipboard entries pasted all together, is there a way to have them on separate lines? Perhaps a macro? Thank you
Chris wrote: A great deal depends on how you define "clipboard' and "multiple clipboard entries", as well as whether your existing code loads the clipboard or not.
The macro "Curious" takes existing contents of the clipboard and parses the contents into sentences, allocating a separate paragraph ("line") to each sentence.
From module modCurious in Utilities_Clipboard.doc
Code:
Option Explicit
Public Function strReplaceAll(ByVal strSource As String, strFind As String, strReplace As String) As String
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''' Function: strReplaceAll
'''
''' Comments: Replace characters within a string.
'''
''' Arguments: STRING String to be massaged
''' STRING Set of characters candidates for removal
''' STRING Set of characters candidates for replacement
'''
''' Returns: STRING
'''
''' Date Developer Action
''' --------------------------------------------------------------------------
''' 2008/12/20 Chris Greaves Created
'''
Dim lngI As Long
Dim lngOldI As Long
lngI = InStr(1, strSource, strFind)
While lngOldI < lngI
lngOldI = lngI
strSource = Left(strSource, lngI - 1) & strReplace & Right(strSource, Len(strSource) - lngI - Len(strFind) + 1)
lngI = InStr(lngOldI + Len(strReplace), strSource, strFind)
Wend
strReplaceAll = strSource
'Sub TESTstrReplaceAll()
' Debug.Assert "d:\\greaves\\products\\" = strReplaceAll("d:\greaves\products\", "\", "\\")
' Debug.Assert " here is a sample string " = strReplaceAll(" here is a sample string ", " ", " ")
' Debug.Assert "I:\ImagesScaled\IMG_20160923_153343233.jpg" = strReplaceAll("I:\ImagesScaled/IMG_20160923_153343233.jpg", "/", "\")
'End Sub
End Function
Sub Curious()
' Convert a set of senetences to a set of paragraphs("lines")
Dim strText As String
strText = strGetFromClipboard
strText = strReplaceAll(strText, ". ", "." & vbCrLf)
Call strClearClipboard
Call strAppendToClipboard(strText)
End Sub
Sub TESTCurious()
Call strClearClipboard
Call strAppendToClipboard("Rather than have multiple clipboard entries pasted all together. Is there a way to have them on separate lines. Perhaps a macro? Thank you. ")
Call Curious
MsgBox strGetFromClipboard
End Sub
This is what it does
Sub Curious()
strText = strGetFromClipboard
It gets any existing text from the clipboard, (in text format GetText(1) – 1 Specifies the standard Windows Unicode text format. https://learn.microsoft.com/en-us/do...owsdesktop-7.0 ), puts that in variable, strText _
strReplaceAll(strText, ". ", "." & vbCrLf)
It does a simple manipulation to change all and any two characters of a dot and space . __ to three characters of a single dot . and a vbCr and a vbLf.
strClearClipboard
It then clears the (windows) clipboard in a strange way: It gets what’s in the clipboard (but does nothing with it) and then puts "" in it
strAppendToClipboard(strText)
It then puts the text back in the (windows) clipboard
??? God knows what that is all about. He is demoing something, to himself I think
Sub TESTCurious()
Call strClearClipboard
Clears the (windows) clipboard in a strange way: It gets what’s in the clipboard (but does nothing with it) and then puts "" in it
Call strAppendToClipboard("Rather than have multiple clipboard entries pasted all together. Is there a way to have them on separate lines. Perhaps a macro? Thank you. ")
Puts the text
__ Rather than have multiple clipboard entries pasted all together. Is there a way to have them on separate lines. Perhaps a macro? Thank you .
in the (windows) Clipboard
Call Curious
Now we go and do the ……
Sub Curious()
strText = strGetFromClipboard
It gets any existing text from the clipboard, ( in this case _ Rather than have multiple clipboard entries pasted all together. Is there a way to have them on separate lines. Perhaps a macro? Thank you. ) , (in text format GetText(1) – 1 Specifies the standard Windows Unicode text format. https://learn.microsoft.com/en-us/do...owsdesktop-7.0 ), puts that in variable, strText _
strReplaceAll(strText, ". ", "." & vbCrLf)
It does a simple manipulation to change all and any two characters of a dot and space . __ to three characters of a single dot . and a vbCr and a vbLf.
strClearClipboard
It then clears the (windows) clipboard in a strange way: It gets what’s in the clipboard (but does nothing with it) and then puts "" in it
strAppendToClipboard(strText)
It then puts the text back in the (windows) clipboard
MsgBox strGetFromClipboard
It shows us that the text has been changed to
Rather than have multiple clipboard entries pasted all together.
_ Is there a way to have them on separate lines.
Perhaps a macro? Thank you.
Conclusion:
This is what is Chris is doing.
Changing this
Code:
Rather than have multiple clipboard entries pasted all together. Is there a way to have them on separate lines. Perhaps a macro? Thank you.
to this
Code:
Rather than have multiple clipboard entries pasted all together.
Is there a way to have them on separate lines.
Perhaps a macro? Thank you.
and doing it in a very convolute and confusing way, involving going back and forwards with the (windows) clipboard via the DataObject
I am not sure why. It’s a bit shirt tail and not quite so relevant to what I think is going on and wanted.
What the OP, curious, wanted ( https://eileenslounge.com/viewtopic....307820#p307820
https://eileenslounge.com/viewtopic....555fc8#p307825 )
See here a post or two down https://www.excelfox.com/forum/showt...ll=1#post20082
https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=UgxsozCmRd3RAmIPO5B4AaABAg. 9fxrOrrvTln9g9wr8mv2CS
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugw6zxOMtNCfmdllKQl4AaABAg
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=UgyT1lo2YMUyZ50bLeR4AaABAg. 9fz3_oaiUeK9g96yGbAX4t
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugx5d-LrmoMM_hsJK2N4AaABAg.9fyL20jCtOI9g7pczEpcTz
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=UgyT1lo2YMUyZ50bLeR4AaABAg. 9fz3_oaiUeK9g7lhoX-ar5
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugx5d-LrmoMM_hsJK2N4AaABAg.9fyL20jCtOI9gD0AA-sfpl
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugx5d-LrmoMM_hsJK2N4AaABAg.9fyL20jCtOI9gECpsAVGbh
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugw6zxOMtNCfmdllKQl4AaABAg. 9g9wJCunNRa9gJGhDZ4RI2
https://www.youtube.com/watch?v=Sh1kZD7EVj0&lc=Ugz-pow-E8FDG8gFZ4l4AaABAg.9f8Bng22e5d9f8hoJGZY-5
https://www.youtube.com/watch?v=Sh1kZD7EVj0&lc=Ugxev2gQt7BKZ0WYMfh4AaABAg. 9f6hAjkC0ct9f8jleOui-u
https://www.youtube.com/watch?v=Sh1kZD7EVj0&lc=Ugxg9iT7MPWGBWruIzR4AaABAg
https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA
-
-
In support of this Thread https://eileenslounge.com/viewtopic....307820#p307820
https://eileenslounge.com/viewtopic....555fc8#p307825
What the OP, curious, wanted
This is what I think we want, and what it’s all about
I don’t think we are so much directly involved with the (Windows) clipboard
I was not sure from the first post, but then Hans reply in the second suggested that the OP, curious would have maybe had done a copy action on some words in a text in WORD, like this example
He had done three copy actions in a WORD doc like this https://i.postimg.cc/y6XSt83V/Three-...le-Entries.jpg
https://i.postimg.cc/pyrTnxB7/Three-...le-Entries.jpg https://i.postimg.cc/y6XSt83V/Three-...le-Entries.jpg
Now he was probably then selecting somewhere convenient and then hitting that Paste All button ( In my German WORD Alle einfügen button), which gives him all three things in a row like this:
https://i.postimg.cc/7YHTkrSS/Paste-All.jpg https://i.postimg.cc/c6zJRj9J/Paste-All.jpg
https://i.postimg.cc/7YHTkrSS/Paste-All.jpg
He was wanting it more like this https://i.postimg.cc/6q02vMx7/Three-...rate-lines.jpg
https://i.postimg.cc/SYnx07sq/Three-...rate-lines.jpg
https://i.postimg.cc/6q02vMx7/Three-...rate-lines.jpg
Now, what is going on there initially is that we are not really directly having so much to do with the (Windows) Clipboard. (We are probably never actually loading the (Windows) Clipboard, but that is a slightly advanced and debateable issue, to do with the theme of deffered entry) . We are not really using the (Windows) Clipboard.
What we are doing is concerning ourselves with the thing sometimes referred to as the Office Clipboard, but which is actually one of a few things that monitors copy action. This Office Clipboard also makes its own copies in some form or another, as indicated in that margin on the left in the screenshot. ( In WORD 2003 and lower you get that up at the right possibly instead ) https://i.postimg.cc/hjV7SSC1/WORD-2...-Clipboard.jpg
https://i.postimg.cc/cCZtCV2y/WORD-2...-Clipboard.jpg
https://i.postimg.cc/FsTkFCx8/WORD-2...-Clipboard.jpg
https://i.postimg.cc/mtFg8wJy/WORD-2...-Clipboard.jpghttps://i.postimg.cc/cg9L55dX/WORD-2...-Clipboard.jpg
Now my proposed solution was that someone smarter than me might be able to figure out a solution from the info here:
http://www.benf.org/excel/officeclip/index.html
That is one of those older Blogs that is often very useful. But I cannot figure it out. At fist glance it seems that it is suggesting a way in VBA to do what is wanted
I think if some WORD expert could do that it would be a very useful and very interesting thing
Alan