Information générale
Catégorie:
COM/DCOM et OLE Automation
maybe i am missing something here, but since you are already in vfp now, just open the table directly instead of a odbc connection, find your data, and then pass it to the excell object/cells.
>Can anybody help me understand how to 'translate' a piece of VB code recorded in Excel into VFP usable code? I have some experience with this, but not as complex as this...
>
>The code below is what I start with... I know that I lose the SUB statement, replace the continuation character (_) with the VFP (;) character, the & with the + etc., but I keep getting a "missing ending )" error.
>
>Where might I look for further guidance on this?
>
>Thanks in advance for any help!
>
>Andrew
>
>Sub QueryTable()
>'
>' QueryTable Macro
>' Macro recorded 22/04/2003 by Andrew Jennings
>'
>
>'
> With ActiveSheet.QueryTables.Add(Connection:= _
> "ODBC;DSN=Visual FoxPro Tables;UID=;PWD=;SourceDB=f:\data\tssimms;SourceType=DBF;Exclusive=No;BackgroundFetch=Yes;Collate=Machine;" _
> , Destination:=Range("A13"))
> .CommandText = Array( _
> "SELECT simhisn.line_no, simhisn.batch_no, simhisn.b_l, simhisn.pro_no" & Chr(13) & "" & Chr(10) & "FROM simhisn simhisn" & Chr(13) & "" & Chr(10) & "WHERE (simhisn.batch_no=$485)" & Chr(13) & "" & Chr(10) & "ORDER BY simhisn.line_no" _
> )
> .Name = "Query from Visual FoxPro Tables"
> .FieldNames = True
> .RowNumbers = False
> .FillAdjacentFormulas = False
> .PreserveFormatting = True
> .RefreshOnFileOpen = False
> .BackgroundQuery = True
> .RefreshStyle = xlInsertDeleteCells
> .SavePassword = True
> .SaveData = True
> .AdjustColumnWidth = True
> .RefreshPeriod = 0
> .PreserveColumnInfo = True
> .Refresh BackgroundQuery:=False
> End With
>End Sub
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement