Newbie: Accessing an Excel worksheet from a Collection
Keith McAlpine <[email protected]>
| Newsgroups | gmane.comp.windows.devel.jawin |
|---|---|
| Message-ID | <LISTSERV%[email protected]> |
Hello,
I have an Excel worksheet that I manupulate with Jawin (performing formula
calculations etc.).
My problem concerns retrieving a worksheet instance from a collection of
worksheets. My code snippet is:
// get collection of worksheets from active workbook
DispatchPtr sheets = app.getObject("Sheets");
DispatchPtr mySheet;
Integer count = sheets.get("Count");
// count contains the correct number of sheets in the workbook (e.g. 10)
// all of these variants return a COMException with "Member not found" msg
mySheet = (DispatchPtr) sheets.invoke("Item", 1);
mySheet = (DispatchPtr) sheets.invoke("Item", new Integer(1));
mySheet = (DispatchPtr) sheets.invoke("Item", "MySheetName");
Whenever I work with the Shapes collection of the ActiveWorksheet, then:
DispatchPtr shapes = workSheet.getObject("Shapes");
Dispatch myShape = (DispatchPtr) shapes.invoke("Item", 1);
works correctly.
Any ideas would be most appreciated. I'm using jawin 1.0.19. I also tried
the stub generator but found that most get() operations were defined as
voids, so I went back to the basic approach.
Thanks
Keith
try {
test = (DispatchPtr)
shapes.invoke("Item", 1);
Object o = test.get("Name");
} catch (Exception ex) {}