Microsoft KB Archive/113443

{|
 * width="100%"|

-

The information in this article applies to:


 * Microsoft FoxPro for Windows, versions 2.5, 2.5a, 2.5b

-

SUMMARY
You can copy a general field from one record to another by using the KEYBOARD command and the copy key combination (CTRL+C) to place the OLE object on the Windows Clipboard. You can then use the paste key combination (CTRL+V) to insert the OLE object in the general field of the target record. For more information about this process, see below.

MORE INFORMATION
Go to the record containing the general field you want to copy. Use the KEYBOARD command to issue CTRL+C and CTRL+W. Open a window for the process to take place.

Go to the record containing the general field you want to contain the OLE object you now have on the Clipboard. Use the KEYBOARD command to issue CTRL+V and CTRL+W. Open a window for the process to take place.

Sample Code
To test the sample code below, you can use the OLETABLE.DBF file in the FOXPROW\SAMPLE\OLE subdirectory. This table contains a general field called OBJECT.

The following code example works on a copy of the database you select. You will have to make the appropriate changes to this code in order to have it work on a live table. Two files are created during the execution of this code (OLETEST.DBF and OLETEST.FPT); you can delete these files when you are finished.   CLOSE DATABASES *COPY and USE the database. testfile= GETFILE('dbf','Select the OLE table') IF FILE('oletest.dbf') ERASE oletest.dbf ERASE oletest.fpt ENDIF IF !EMPTY(testfile) COPY FILE (testfile) TO oletest.dbf COPY FILE LEFT(testfile,LEN(testfile)-3)+"FPT" TO oletest.fpt USE oletest

ELSE WAIT WINDOW TIMEOUT 1.5 'No table selected...' RETURN ENDIF

*Set record pointer to source record BROWSE TITLE 'Select source record by moving to it... '+;     'Press  to select record' fieldname='OLETEST.OBJECT'

DEFINE WINDOW updt_ole AT 5,15 SIZE 2,90 FONT "FoxPrint" TITLE ; "Copying general field &fieldname from record "+LTRIM(STR(RECNO)) ACTIVATE WINDOW updt_ole

KEYBOARD '{Ctrl+C}' KEYBOARD '{Ctrl+W}' MODIFY GENERAL (fieldname) IN WINDOW updt_ole

RELEASE WINDOW updt_ole

*Set record pointer to destination record BROWSE TITLE 'Select destination record... Press  to select it' fieldname='OLETEST.OBJECT'

DEFINE WINDOW copymsg AT 5,15 SIZE 2,90 FONT "FoxPrint" TITLE ; "Pasting to &fieldname in record "+LTRIM(STR(RECNO)) ACTIVATE WINDOW copymsg

KEYBOARD '{Ctrl+V}' KEYBOARD '{Ctrl+W}' MODIFY GENERAL (fieldname) IN copymsg

RELEASE WINDOW copymsg WAIT WINDOW NOWAIT "Done!" Additional query words: FoxWin 2.50

Keywords         : kbcode FxinteropOle Version          : 2.50 2.50a 2.50b Platform         : WINDOWS Issue type       :
 * }