Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Excel Syntax from VFP8
Message
From
25/06/2004 12:14:55
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00917279
Message ID:
00917283
Views:
16
>I am working with VFP8 and Excel 2000 to pass some data and then have a macro in excel distribute the data to different sheets. One of the requirements I am trying to do from VFP is to create a Named Range. The values of the range is based on the number of records in the table. The problem I am having is the proper syntax to create the Name in Excel. Here is my code:
>
>oexcel = CreateObject("Excel.Application")
>oexcel.Workbooks.Open("profile.xls")
>oexcel.Sheets("CRITERIA").Activate
>L_NRECCNT=5
>l_cname="('top5','=CRITERIA!$A20:$L$"+ALLTRIM(STR(L_NRECCNT))+"')"
>oexcel.ActiveWorkbook.Names.Add(&L_CNAME)
>
>I get an error message of "Function name is missing )."
>I have tried different variations of the call "oexcel.ActiveWorkbook.Names.Add(&L_CNAME)" but have not succeeded yet.
>
>Any Ideas??
>
>Thanks.

One frequent cause of problems, in Excel Automation, is invoking the wrong object. Check the help, or experiment, whether .Names.Add() applies to a spreadsheet, a workbook, or the Excel object itself (the latter is unlikely in this case).
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Reply
Map
View

Click here to load this message in the networking platform