Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Help with excel/foxpro syntax
Message
De
30/12/1999 07:13:16
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
29/12/1999 09:18:40
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00309795
Message ID:
00310285
Vues:
25
>Hi All,
>
>can anyone tell me the proper syntax for the following VBA code. I am trying to use the chart wizard from foxpro.
>
>thanks
>James
>ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("A1:B4"), PlotBy:= xlcolumns


Hi James,
Martin already provided a lot of info on this. I want to notify your missing part in this syntax so future syntax won't catch you :)
This doesn't work basically because object hierarchy is not completed. Whenever you cut&paste macro code check leftmost object's "applies to" in help. Correct syntax should be (assuming ox is excel.application object and an activeworkbook exists, an activechart as well):

ox.ActiveChart.SetSourceData(ox.activeworkbook.worksheets("Sheet1").range("A1:C4"), xlColumns)

Instead of activechart you could also refer to it as :
ox.Charts("Chart1").SetSourceData(...
Here I assumed you have at least one chart and its name is default (name not changed).

If chart is added to a worksheet (not as a separate sheet) then object reference changes to :
ox.ActiveWorkBook.ActiveSheet.ChartObjects(nIndexOrcName).SetSourceData(...

Active* could be changed with collection counterparts like workbooks(nIndexOrcName) and WorkSheets(nIndexOrcName) respectively.

Also notice that named arguments ( Source:=Sheets("Sheet1").Range("A1:B4") and PlotBy:= xlcolumns ) are converted to positional arguments in fox ( ox.activeworkbook.worksheets("Sheet1").range("A1:C4") and xlColumns respectively). Fox doesn't use named arguments (wish it does in next version). To your chance position for the arguments were exactly the same as in macro recorded code for this one. Better also check the syntax in help and if necessery put the arguments in correct positions. ie:

Address have 2 syntaxes where (Syntax 2) is :
expression.Address(RowAbsolute, ColumnAbsolute, ReferenceStyle, External, RelativeTo)
And says :
expression Required. An expression that returns a Hyperlink object (Syntax 1) or a Range object (Syntax 2).

Help also says all parameters are "optional variants". IOW they're optional variables. Suppose you want to get address of selection. Selection if a cell(s) are selected then returns a Range object (what we need for "expression" part) and applies to Application and window. So this would be a valid "expression" when there some cell(s) selected :
ox.Selection

Now suppose we want the address in xlA1 style and don't bother with other parameters (use defaults). Then fox syntax becomes :

ox.Selection.Address(,,xlA1)

Fill the "optional variants" till the one we want to define with commas and simply ignore the rest.

Macro could refer the same syntax as :

Selection.Address( ReferenceStyle := xlA1 )

These are generally what VBA macros catch we foxers :)
Best regards.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform