Hi I have the ffw problem: This adds a new Worksheet to an existing workbook xlSheet2 := xlBook.Sheets.Add(); The Add-Method has 4 parameters (see F5 in Navision). 1) Insert before 2) Insert after … As I understand this, only 1 out of the first 2 parameters can be passed (either before a sheet or after a sheet). What I want is to define the current sheet as the second parameter. Is it possible to omit the first parameter? Unfortunately …add(,Sheet1) creates a compiling error. Thanks in advance H
You can not omit leading optional parameters in C/AL, you have to specify a value for all parameters preceding the one you actually want to pass. You can omit trailing optionals, though.
Hi Thank you. Unfortunalety the first parameter has to be empty, because Par1 is “Insert before”, Par2 is “Insert after”. If I have one existing sheet and want to insert one additional sheet, I have to use the second paramameter. I tried various values in Par1, for example ‘NULL’, ‘NIL’ with no success. Regards H
What is the data type of the parameter you wish to omit? Is it not possible to call the function with an harmless value for this parameter - like FALSE for Boolean, 0 for Integer or ‘’ for Text?
Hello Nelson, This function expects parameters of type (Work)Sheet, so there’s no harmless C/AL constant one could pass… Well, maybe 0 would be worth another try. In VB, you could use named parameters, but this is not available in C/AL either. Personally, I have always tried to avoid this function in my Excel Automation reports and never guarantee a specific ordering of the sheets in the resulting file [;)].
Humm, I was just trying it out a little. Tried a Variant variable but to no avail. Maybe your (non-)solution is the best… [:D]