ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   clipboard (https://www.excelbanter.com/excel-programming/327492-clipboard.html)

gabor salai

clipboard
 
with "copy/paste" [say some range], does excel use clipboard, or some
internal structure?
after "copy", is it possible to somehow access that buffer [before "paste"],
and to examine it, or even programaticaly select [or apply] just a part of
buffer.
it is something like "paste special" does, but i would like to have *full*
[free] user intervention.
it would be also intersting to programaticaly [freely] *fill* that
"copy/paste" buffer.



keepITcool

clipboard
 
well...

Clpbrd.exe will tell you what's on the clipboard.
copy a cell and check it out.

Be sure to use the View dropdown to see all the datatypes
such a 'basic copy' puts in the clipboard.

Freely filling the clipboard cannot be easily done VBA,
you'll need to use API's for that and it will be very complex
if you go beyond the very basic (documented) datatypes


--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


gabor salai wrote :

with "copy/paste" [say some range], does excel use clipboard, or some
internal structure?
after "copy", is it possible to somehow access that buffer [before
"paste"], and to examine it, or even programaticaly select [or apply]
just a part of buffer.
it is something like "paste special" does, but i would like to have
full [free] user intervention.
it would be also intersting to programaticaly [freely] fill that
"copy/paste" buffer.


K Dales[_2_]

clipboard
 
I have manipulated the clipboard using APIs and keepITcool is right - it
isn't easy to do much beyond the basics. I am not sure what you have in
mind, but here's an idea: create either a hidden sheet or at least a hidden
range somewhere. Do a Range.Paste operation into that range and then use
your code to examine or manipulate the results. Then copy back into the
clipboard if needed. In other words, you are creating your own "buffer" on
the sheet, temporarily. Still has some drawbacks (e.g. what would happen if
the clipboard contained a picture?) but it might let you do some processing
of what is in the clipboard before proceding with whatever it is you need to
do. Just a thought.

"keepITcool" wrote:

well...

Clpbrd.exe will tell you what's on the clipboard.
copy a cell and check it out.

Be sure to use the View dropdown to see all the datatypes
such a 'basic copy' puts in the clipboard.

Freely filling the clipboard cannot be easily done VBA,
you'll need to use API's for that and it will be very complex
if you go beyond the very basic (documented) datatypes


--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


gabor salai wrote :

with "copy/paste" [say some range], does excel use clipboard, or some
internal structure?
after "copy", is it possible to somehow access that buffer [before
"paste"], and to examine it, or even programaticaly select [or apply]
just a part of buffer.
it is something like "paste special" does, but i would like to have
full [free] user intervention.
it would be also intersting to programaticaly [freely] fill that
"copy/paste" buffer.



gabor salai

clipboard
 
[rearanged]

gabor salai wrote :

with "copy/paste" [say some range], does excel use clipboard, or some
internal structure?
after "copy", is it possible to somehow access that buffer [before
"paste"], and to examine it, or even programaticaly select [or apply]


"keepITcool" wrote in message
ft.com...
well...

Clpbrd.exe will tell you what's on the clipboard.
copy a cell and check it out.


thanks, i wanted to access clipboard [or whatever buffer excel employes]
from *within* excel macro, not from clipboard_viewer!

something like:

set myrange=getclipboard.range(1)
value1=myrange.cells(1,2).value

where cells from clipboarded region should count relatively to upper_left
corner of selection captured by "copy"






keepITcool

clipboard
 
Gabor,

as I said the clipboard is not exposed thru VBA, you'll need API's.

mentioning clpbrd.exe was to demonstrate that YES excel uses the global
clipboard in a multitude of formats.

it was a serious answer that you obviously interpreted the wrong way.



--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


gabor salai wrote :

[rearanged]

gabor salai wrote :

with "copy/paste" [say some range], does excel use clipboard, or
some internal structure?
after "copy", is it possible to somehow access that buffer [before
"paste"], and to examine it, or even programaticaly select [or
apply]


"keepITcool" wrote in message
ft.com...
well...

Clpbrd.exe will tell you what's on the clipboard.
copy a cell and check it out.


thanks, i wanted to access clipboard [or whatever buffer excel
employes] from within excel macro, not from clipboard_viewer!

something like:

set myrange=getclipboard.range(1)
value1=myrange.cells(1,2).value

where cells from clipboarded region should count relatively to
upper_left corner of selection captured by "copy"


gabor salai

clipboard
 
"keepITcool" wrote in message
ft.com...
Gabor,

as I said the clipboard is not exposed thru VBA, you'll need API's.

mentioning clpbrd.exe was to demonstrate that YES excel uses the global
clipboard in a multitude of formats.

it was a serious answer that you obviously interpreted the wrong way.



sorry, i just wanted to be sure that been understood well.
and sorry again for vba missing clipboard functionality.



--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


gabor salai wrote :

[rearanged]

gabor salai wrote :

with "copy/paste" [say some range], does excel use clipboard, or
some internal structure?
after "copy", is it possible to somehow access that buffer [before
"paste"], and to examine it, or even programaticaly select [or
apply]


"keepITcool" wrote in message
ft.com...
well...

Clpbrd.exe will tell you what's on the clipboard.
copy a cell and check it out.


thanks, i wanted to access clipboard [or whatever buffer excel
employes] from within excel macro, not from clipboard_viewer!

something like:

set myrange=getclipboard.range(1)
value1=myrange.cells(1,2).value

where cells from clipboarded region should count relatively to
upper_left corner of selection captured by "copy"




keepITcool

clipboard
 
a quick sample of complexity:
this will ONLY get you the size of any range data on the clipboard:

adapted from thread:
Row_count in clipboard oct8,2004

Option Explicit

Const CF_SYLK = 4
Const CF_DSPTEXT = &H81

Declare Function OpenClipboard Lib "user32" ( _
ByVal Hwnd As Long) As Long
Declare Function CloseClipboard Lib "user32" () As Long


Declare Function IsClipboardFormatAvailable Lib "user32" ( _
ByVal wFormat As Long) As Long
Declare Function GetClipboardData Lib "user32" ( _
ByVal wFormat As Long) As Long

Declare Function GlobalLock Lib "kernel32" ( _
ByVal hMem As Long) As Long
Declare Function GlobalUnlock Lib "kernel32" ( _
ByVal hMem As Long) As Long
Declare Function GlobalSize Lib "kernel32" ( _
ByVal hMem As Long) As Long
Declare Function lstrcpy Lib "kernel32" ( _
ByVal lpString1 As Any, ByVal lpString2 As Any) As Long
Declare Function lstrlen Lib "kernel32" Alias "lstrlenA" ( _
ByVal lpString As String) As Long

Function CBRows()
CBRows = ClipBoard_RangeSize(0)
End Function
Function CBCols()
CBCols = ClipBoard_RangeSize(1)
End Function

Function ClipBoard_RangeSize()
'author: keepITcool Oct 9, 2004
'does NOT work for xl97

Dim lhCB&, lpCB&, lRet&, lSize&, sText$
Dim aTmp, sTmp$, nRow&, nCol&

If IsClipboardFormatAvailable(CF_SYLK) Then
If OpenClipboard(0&) < 0 Then
lhCB = GetClipboardData(CF_DSPTEXT)
If lhCB < 0 Then
lpCB = GlobalLock(lhCB)
If lpCB < 0 Then
lSize = GlobalSize(lpCB)
sText = Space$(lSize)
lRet = lstrcpy(sText, lpCB)
lRet = GlobalUnlock(lhCB)
sText = Left(sText, InStr(1, sText, Chr$(0), 0) - 1)
End If
End If
CloseClipboard
End If
If sText Like "* *#? x *#?" Then
aTmp = Split(sText, Space$(1))
nRow = Val(aTmp(UBound(aTmp) - 2))
nCol = Val(aTmp(UBound(aTmp)))
End If
End If
ClipBoard_RangeSize = Array(nRow, nCol)
End Function











--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


gabor salai wrote :

"keepITcool" wrote in message
ft.com...
Gabor,

as I said the clipboard is not exposed thru VBA, you'll need API's.

mentioning clpbrd.exe was to demonstrate that YES excel uses the
global clipboard in a multitude of formats.

it was a serious answer that you obviously interpreted the wrong
way.



sorry, i just wanted to be sure that been understood well.
and sorry again for vba missing clipboard functionality.



--
keepITcool
www.XLsupport.com | keepITcool chello nl | amsterdam



gabor salai wrote :

[rearanged]

gabor salai wrote :

with "copy/paste" [say some range], does excel use clipboard,
or some internal structure?
after "copy", is it possible to somehow access that buffer
[before "paste"], and to examine it, or even programaticaly
select [or apply]

"keepITcool" wrote in message
ft.com...
well...

Clpbrd.exe will tell you what's on the clipboard.
copy a cell and check it out.

thanks, i wanted to access clipboard [or whatever buffer excel
employes] from within excel macro, not from clipboard_viewer!

something like:

set myrange=getclipboard.range(1)
value1=myrange.cells(1,2).value

where cells from clipboarded region should count relatively to
upper_left corner of selection captured by "copy"



All times are GMT +1. The time now is 12:37 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com