PRB: Error Passing Multiple Parameters to DataToClip Method
ID: Q156177
|
The information in this article applies to:
-
Microsoft Visual FoxPro for Windows, versions 5.0, 6.0
SYMPTOMS
A syntax error occurs when attempting to pass more than one parameter to
the DataToClip method of a Visual FoxPro application object from a
Microsoft Excel module.
CAUSE
The DataToClip method must be called as a command rather than a function in
order to pass multiple parameters.
WORKAROUND
Use the following syntax to pass parameters to the DataToClip method:
oObject.DataToClip lpvarWrkArea:=cCursorName,
lpvarNumRows:=nNumRows, lpvarClipFormat:=nFormat
MORE INFORMATION
The DataToClip method copies a set of records as text to the Clipboard. It
takes the following three parameters:
Steps to Reproduce Behavior
Paste the following code into a new Microsoft Excel module and run it. You
do not have to specify the variable names when calling the DataToClip
method:
Public FoxApp As Object
Sub copyFoxdata()
' Starts the Visual FoxPro OLE Server
Set FoxApp = CreateObject("VisualFoxPro.Application")
' Closes any data files that may be open
FoxApp.Docmd ("CLOSE DATA")
' Sets the default path for the FoxPro server
' Change this path to match your Visual FoxPro directory
FoxApp.DefaultFilePath = "d:\VFP50\Samples\Data"
' Opens the sample Customer table
FoxApp.Docmd ("USE customer")
' The next 2 commands perform the same function: to copy the
' first record to the clipboard in the default format, which is
' delimited with spaces
FoxApp.DataToClip "customer", 1
FoxApp.DataToClip lpvarWrkArea:="customer", lpvarNumRows:=1
' Paste the Data onto a Sheet of the Active Workbook
ActiveWorkbook.Sheets(1).Activate
ActiveSheet.Paste
' The next 2 commands perform the same function: to copy the
' first record to the clipboard delimited with tabs
FoxApp.DataToClip "customer", 1, 3
' This command should be on one line
FoxApp.DataToClip lpvarWrkArea:="customer", lpvarNumRows:=1,
lpvarClipFormat:=3
' Paste the Data onto a Sheet of the Active Workbook
ActiveWorkbook.Sheets(2).Activate
ActiveSheet.Paste
' The next 2 commands perform the same function: to copy all records
' to the clipboard delimited with tabs
FoxApp.DataToClip "customer", , 3
FoxApp.DataToClip lpvarWrkArea:="customer", lpvarClipFormat:=3
' Paste the Data onto a Sheet of the Active Workbook
ActiveWorkbook.Sheets(3).Activate
ActiveSheet.Paste
' The next two commands end the Visual FoxPro session
FoxApp.Quit
Set FoxApp = Nothing
End Sub
Additional query words:
kbdsd VFoxWin
Keywords : kbVFp500 kbVFp600 FxinteropExcel
Version : WINDOWS:5.0,6.0
Platform : WINDOWS
Issue type :