PRB: Error Passing Multiple Parameters to DataToClip MethodLast reviewed: January 10, 1997Article ID: Q156177 |
The information in this article applies to:
SYMPTOMSA 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.
CAUSEThe DataToClip method must be called as a command rather than a function in order to pass multiple parameters.
WORKAROUNDUse the following syntax to pass parameters to the DataToClip method:
oObject.DataToClip lpvarWrkArea:=cCursorName,
lpvarNumRows:=nNumRows, lpvarClipFormat:=nFormat
MORE INFORMATIONThe DataToClip method copies a set of records as text to the Clipboard. It takes the following three parameters:
Steps to Reproduce BehaviorPaste 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(4).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(5).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(6).Activate
ActiveSheet.Paste
' The next two commands end the Visual FoxPro session
FoxApp.Quit
Set FoxApp = Nothing
End Sub
|
KBCategory: kbole kbprg kbprb
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |