Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / May 2006

Tip: Looking for answers? Try searching our database.

Place Clipboard Info into Variable

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Debra Ann - 25 Apr 2006 15:17 GMT
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?

Signature

Debra Ann

Greg Maxey - 25 Apr 2006 15:32 GMT
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
Brett - 11 May 2006 21:21 GMT
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

> Sub ScratchMacro()
> Dim MyData As DataObject
[quoted text clipped - 8 lines]
> See:
> http://word.mvps.org/FAQs/MacrosVBA/ManipulateClipboard.htm
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.