+ Reply to Thread
Results 1 to 2 of 2

vba syntax to paste clipboard content

Hybrid View

  1. #1
    Registered User
    Join Date
    03-27-2014
    Location
    Salem, Tamil Nadu, India
    MS-Off Ver
    Excel 2007
    Posts
    36

    Question vba syntax to paste clipboard content

    hi gurus, what is the vba syntax for paste the clipboard content value?

  2. #2
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: vba syntax to paste clipboard content

    Hi VINOTHBASKRAN,

    The following code should help you:
    Option Explicit
    
    'In the debugger:
    'Tools -> References -> Microsoft Forms 2.0 Object Library (Excel 2003 version)
    'or you will get a "Compile error: user-defined type not defined"
    
    Sub PutSomethingInClipboard()
      Dim mydataobj As New MSForms.DataObject
      mydataobj.SetText 123
      mydataobj.PutInClipboard
    End Sub
    
    Sub RetrieveClipboardData()
      Dim DataObj As New MSForms.DataObject
      Dim S As String
      DataObj.GetFromClipboard
      S = DataObj.GetText
      Debug.Print S 'print code in the debugger immediate window (CTRL - G)
    End Sub
    
    Sub ClearClipboardData()
      'NOTE:  'DataObj.Clear' does not always work
      Dim DataObj As New MSForms.DataObject
      DataObj.SetText ""
      DataObj.PutInClipboard
    End Sub
    Lewis
    Last edited by LJMetzger; 11-13-2014 at 09:03 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Copy cell content to clipboard to paste into a pdf
    By kevinm3u in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-06-2014, 03:30 PM
  2. macro to move 1 cell left and paste CURRENT clipboard content as HYPERLINK
    By sgoesef in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-28-2013, 01:31 PM
  3. [SOLVED] Store clipboard before "vba do cut&paste" then recover stored information to clipboard?
    By Marie J-son in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-08-2006, 02:00 AM
  4. Clipboard content window
    By Shanks in forum Excel General
    Replies: 1
    Last Post: 06-02-2005, 08:05 AM
  5. Put in clipboard, but keep the current content
    By Eric van Uden in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-25-2005, 05:06 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1