Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Automating Controls in Excel
Message
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00735409
Message ID:
00735471
Views:
7
This is the code I was using to test OLEOBJECTS, but I soon realized that it wasn't finding the controls on each sheet.

lcFile = GETFILE("XLS")
IF EMPTY(lcFile)
RETURN
ENDIF

oExcel = CREATEOBJECT("Excel.application")
oWorkbook = oExcel.Workbooks.OPEN(lcFile)
lnSheetCnt = oWorkbook.Worksheets.COUNT

? lcFile && Display XLS file name

FOR lnSheet = 1 TO lnSheetCnt
oWorkSheet = oWorkbook.Worksheets(lnSheet)

? "Sheet #" + ALLTRIM(STR(lnSheet)) + " (" + ALLTRIM(oWorkSheet.NAME) + ")" && Display Sheet Number and Name
? SPACE(5) + "Object Count: " + ALLTRIM(STR(oWorkSheet.OLEOBJECTS.COUNT)) && Display Object Count

FOR nObj = 1 TO oWorkSheet.OLEOBJECTS.COUNT
? SPACE(5) + oWorkSheet.OLEOBJECTS.NAME && Display each object on this sheet
NEXT
NEXT

oExcel.Quit()
RELEASE oWorkSheet, oWorkbook, oExcel
RETURN

>How do you call oleobjects? AFAIK, they belong to particular sheet:

>?ObjExcel.Worksheets(2).OLEObjects.Count

>>I'm currently writing a program to automate the creation of a purchase order for my company. The spreadsheet already exists and I have no problem filling in the cell values. The problem is that there are option buttons, checkboxes, comboboxes that I need to check the current value and then write a new value. I've looked at the Excel object model many times and I must be missing something. I thought I found the solution by using the OLEOBJECTS collection but each sheet had a COUNT of 0.
>>
>>Any help would be appreciated. Thanks.
>>
>>Aaron Jacka
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform