K
Ken Loomis
Is there a way to determine how many rows are stored on the clipboard?
Ken Loomis
Ken Loomis
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
sTmp = aTmp(UBound(aTmp) - 2)
nRow = Left(sTmp, Len(sTmp) - 1)
sTmp = aTmp(UBound(aTmp))
nCol = Left(sTmp, Len(sTmp) - 1)
keepITcool said:not easy...
This worked in xlXP and xl2003, but didnt work in xl97
usage would be:
numRows = Clipboard_RangeSize(0)
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 GlobalAlloc Lib "kernel32" (ByVal wFlags&, ByVal
dwBytes 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 ClipBoard_RangeSize()
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
aTmp = Split(sText, " ")
If UBound(aTmp) > 2 Then
sTmp = aTmp(UBound(aTmp) - 2)
nRow = Left(sTmp, Len(sTmp) - 1)
sTmp = aTmp(UBound(aTmp))
nCol = Left(sTmp, Len(sTmp) - 1)
End If
End If
ClipBoard_RangeSize = Array(nRow, nCol)
End Function
keepITcool
< email : keepitcool chello nl (with @ and .) >
< homepage: http://members.chello.nl/keepitcool >

Dana DeLouis said:Thanks "keepITcool." Didn't think about that. I'm just messing
around with an alternative ending ...
'// Your code here... then.
Select Case Application.CutCopyMode
Case xlCopy, xlCut
v = Split(sText, Space(1))
ClipBoard_RangeSize = Array(Val(v(1)), Val(v(3)))
Case Else
ClipBoard_RangeSize = Array(0, 0)
End Select
End Function

Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.