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.9fxrOrrvTln9g9wr8mv2 CS
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=Ugw6zxOMtNCfmdllKQl4AaABAg
https://www.youtube.com/watch?v=U76ZRIzBhOA&lc=UgyT1lo2YMUyZ50bLeR4AaABAg.9fz3_oaiUeK9g96yGbAX 4t
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.9g9wJCunNRa9gJGhDZ4R I2
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
Bookmarks