Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    Oct 2002
    Location
    Toronto, Ontario, Canada
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Copying & pasting programmatically (Windows & office XP)

    Hello.
    I have an Access application that retrieves certain data based on some criteria. What I would like to do is place the data on the clipboard so the user can paste it into another application. Can it be done using VBA in Access?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Copying & pasting programmatically (Windows & office XP)

    If you can display the data in a form, you can use RunCommand instructions. For example to copy the current record to the clipboard:

    RunCommand acCmdSelectRecord
    RunCommand acCopy

    or to select all records:

    RunCommand acCmdSelectAllRecords
    RunCommand acCopy

  3. #3
    New Lounger
    Join Date
    Oct 2002
    Location
    Toronto, Ontario, Canada
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Copying & pasting programmatically (Windows & office XP)

    Thanks, It is in a form but it's in a variable. Currently it gats displayed using the MsgBox, but the user has to copy the info down. I will try the RunCommand.

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Copying & pasting programmatically (Windows & office XP)

    Access often has unique commands. In Word and other Office applications, it's common to add a references to the MSForms library and use the methods of its DataObject object to put text onto, or retrieve text from, the Windows clipboard.

  5. #5
    5 Star Lounger st3333ve's Avatar
    Join Date
    May 2003
    Location
    Los Angeles, California, USA
    Posts
    705
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: Copying & pasting programmatically (Windows & office XP)

    Toward the end of this article -- http://www.microsoft.com/officedev/articles/movs109.htm -- is the code for a VBA "Clipboard" class module that wraps various API calls (that you don't have to think about) into a Clipboard object that lets you easily assign a string to (or retrieve a string from) the Windows clipboard.

Posting Permissions

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