Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use DataToClip to send data to the Windows clipboard

Status
Not open for further replies.

foxdev

Programmer
Feb 11, 2000
1,995
US
You probably already know that you can assign a text string to _CLIPTEXT to place text onto (or read text from) the Windows clipboard.

But what if you wanted to put record data, especially for more than one record? For example, you want to put some summary data that you compiled using SELECT...GROUP BY onto the Windows clipboard so that the user could paste it onto a spreadsheet or word processing program.

DataToClip to the rescue! This is a method of the VFP application object, so we'll need to prepend the _VFP object reference to any calls to it.

The syntax of DataToClip is:

[tab]_VFP.DataToClip(cAlias or nArea, nNumofRecs, nFormat)

All of these are optional; the default is the current work area/alias, all of the records, and fields separated by spaces. Use the nFormat of 3 to separate fields by tabs; this seems to work the best when pasting into Excel.

This example puts all records in the currently selected alias onto the Windows clipboard:

[tab]nNumRecsCopied = _vfp.datatoclip( , ,3)

notice the use of blanks/commas in place of the ommited first and second parameters. After issuing the above command (with a table already open), I can open Excel and ^V the data with each column placed appropriately. Cool.

Robert Bradley

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top