Thanks keepITcool !! Very nice. I've always wanted to grab that string
from the clipboard. Great!! :)
I made a small change by using Val, which will just take the leading
numbers.
If sText Like "Copy *R x *C" Then
v = Split(sText, Space(1))
nRow = Val(v(1))
nCol = Val(v(3))
End If
Instead of:
sTmp = aTmp(UBound(aTmp) - 2)
nRow = Left(sTmp, Len(sTmp) - 1)
sTmp = aTmp(UBound(aTmp))
nCol = Left(sTmp, Len(sTmp) - 1)
Just for my own curiosity, I would be curious to learn if this would work on
the Mac. Just guessing, but my gut feeling is that it would not work on the
Mac. I think the Mac actually puts Excel's copied data on the Windows
Clipboard. Any feedback would be appreciated.
Anyway, thanks again. :)
--
Dana DeLouis
Win XP & Office 2003
"keepITcool" wrote in message
...
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
"Ken Loomis" wrote:
Is there a way to determine how many rows are stored on the clipboard?
Ken Loomis