Results 1 to 5 of 5

Thread: backup clipboard data, and restore it later

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2006
    Posts
    12

    backup clipboard data, and restore it later

    how do i backup clipboard data? meaning i don't care what kind of format is currently stored in clipboard, but i just want to backup it to a variable or something?

    after backup i got to do something with it, after that it's time to restore the prevly backed up data back to clipboard. how to restore it?

    anyone know how to do these?

  2. #2
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,284

    Re: backup clipboard data, and restore it later

    to just store whatever is in the clipboard:

    Dim iData As IDataObject = Clipboard.GetDataObject()

    then to send it back to the clipboard:

    Clipboard.SetDataObject(iData)

    i got this from the VB help in the IDE too...

  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2006
    Posts
    12

    Re: backup clipboard data, and restore it later

    when my program until to this line Clipboard.SetDataObject(iData), exception eccur says clipboard operation failed.
    why?

  4. #4
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    105,461

    Re: backup clipboard data, and restore it later

    Perhaps you should give the exact error message. The type of the exception wouldn't hurt either. The more relevant information you give the better chance we have of being able to work out the issue. Help us to help you.

  5. #5

    Thread Starter
    New Member
    Join Date
    Jan 2006
    Posts
    12

    Re: backup clipboard data, and restore it later

    assume i have copied a text to clipboard before running these code

    Dim ab As Boolean = Clipboard.GetDataObject.GetDataPresent(DataFormats.Text) 'it return true
    dim cBoardBackup as IDataObject = Clipboard.GetDataObject()

    Clipboard.SetDataObject(vbNull) 'Clear it

    Dim c As Boolean = cBoardBackup.GetDataPresent(DataFormats.Text) 'it returns false
    Clipboard.SetDataObject(cBoardBackup, True) 'fail : error

    i guess wwhy it could fail is because cBoardBackup is a reference to clipboard only, so when i set it to null, then cBoardBackup will become nothing, when i set cBoardBackup back to clipboard then it failed.

    any solution?

Posting Permissions

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



Click Here to Expand Forum to Full Width