I want to place the information contained in the clipboard (which is an
integer) into a variable so that I can increment the number and place it
somewhere else in my document. How do I do that?


--
Debra Ann

Re: Place Clipboard Info into Variable by Greg

Greg
Tue Apr 25 09:32:51 CDT 2006

Sub ScratchMacro()
Dim MyData As DataObject
Dim strClip As String
Set MyData = New DataObject
MyData.GetFromClipboard
strClip = MyData.GetText
ActiveDocument.Variables("Test").Value = CLng(strClip) + 1
MsgBox ActiveDocument.Variables("Test").Value
End Sub


See:
http://word.mvps.org/FAQs/MacrosVBA/ManipulateClipboard.htm


Re: Place Clipboard Info into Variable by Brett

Brett
Thu May 11 15:21:01 CDT 2006

I used code in Greg Maxey post as a template in the
following. If there is nothing in the clipboard, it gives
a run time error at the line:
clipText = dObj.GetText

(Is there a way to capture the msgBox text -- its fairly long).

The whole reason for doing this function is to detect if
someone should have copied, but didn't -- so a paste
command wouldn't bomb with a cryptic error message
for non programmers.

Now it bombs with a different cryptic error message -- is
there a way to check that clipboard is empty so you can
quit gracefully?

Any help is much appreciated

' Pass the min Length that should be in clipboard in 'minTextSize'
' If actual clipboard size is less than that, return False, otherwise return
True
' Also return the actual clipboard text in 'clipText' for additional tests
' in calling code if needed
Function pastedEnough(minTextSize As Long, clipText As String) As Boolean
Dim dObj As DataObject

Set dObj = New DataObject
dObj.GetFromClipboard
clipText = dObj.GetText

If (Len(clipText) < minTextSize) Then
pastedEnough = False
Exit Function
End If

pastedEnough = True
End Function





"Greg Maxey" wrote:

> Sub ScratchMacro()
> Dim MyData As DataObject
> Dim strClip As String
> Set MyData = New DataObject
> MyData.GetFromClipboard
> strClip = MyData.GetText
> ActiveDocument.Variables("Test").Value = CLng(strClip) + 1
> MsgBox ActiveDocument.Variables("Test").Value
> End Sub
>
>
> See:
> http://word.mvps.org/FAQs/MacrosVBA/ManipulateClipboard.htm
>
>