hi,
i recently had to convert an VB MSExel macro to OO Starbasic in Calc. I've
previously ported macros with VBASupport and only had to apply minor changes
to code, but this time i came across several bigger problems.
i had to convert a macro, that used
- Application.GetSaveAsFilename, GetOpenFilename
- ThisWorkbook.Saveas, Workbooks.Open
to open a different Excel Workbook and copy date from it.
Openoffice VBASupport doesn't provide support for those MSExcel functions,
so i used
- com.sun.star.ui.dialogs.FIlePicker and
- com.sun.star.frame.Desktop
to open an external MSExcel Workbook.
The problem was, that as soon as i opened a file the complete Excel context
created by OO VBASupport was lost. By lost, i mean i couldn't access
Worksheets("sheetname") because a runtime exception said that it couldn't
find an active workbook. So almost all other Excel functions didn't work as
well because they require some kind of parent context. "Cells" could not be
called anymore because no sheet was active, so no cell based operations were
possible.
So i thought, no problem, let's just use Workbooks("workbookname").Activate,
but that unluckily isn't available to OO VBASupport. I couldn't find
anything similar to tell the open OO spreadsheet Excel functions which
workbook was active or should be activated.
Because i was in a hurry, i simply converted the complete macro to
Starbasic, that simply meant rewriting everything, from selecting to sorting
and many more operations.
Now i finally have the time to investigate for future macros like this. So,
is there a possibility to restore the workbook context somehow, or to not
lose it in first place by opening a different one, so i can use VBASupport
on the rest of the macro?
thanks four your time.
--
------------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected] with Subject: help