[Libreoffice] [Patch]Add method Copy to ScVbaWorksheets
Markus Mohrhard
markus.mohrhard at googlemail.com
Fri Apr 8 17:37:54 PDT 2011
Hello Noel,
> starting with a workbook with the following sheets 'sheet1', 'sheet2' and
> 'sheet3'
> and trying a macro like:
>
> sub test
> worksheets.copy after:=worksheets(2)
> end sub
>
> results in the following sheets in the workbook 'sheet1', 'sheet2',
> 'sheet1_2', 'sheet2_2', 'sheet1_2_2', 'sheet3'
> the expected result should be something like 'sheet1', 'sheet2',
> 'sheet1_2', 'sheet2_2', 'sheet3_2', 'sheet3'
>
> and similarly running the following macro
>
> sub test
> worksheets.copy before:=worksheets(2)
> end sub
>
> results in a workbook with the following sheets 'sheet1', 'sheet1_2',
> 'sheet1_2_2', 'sheet1_2_2_2', 'sheet2', 'sheet3'
> expected results would be 'sheet1', 'sheet1_2', 'sheet2_2', 'sheet3_2',
> 'sheet2','sheet3'
>
> I think you are falling victim to the fact that you are modifying the
> underlying container ( e.g. the sheets container ) whilst iterating over it.
>
No I wasn't. I just used the method a bit different to you. It seems that
there are two possible ways a XWorksheets object is used. First is your use
case in which you specify to copy all sheets. I, in contrast, didn't know
that was possible and used the syntax provided by the bug report:
Sheets(Array(1,2,3)).Copy Before:=Sheets(2) which works fine because a new
worksheets object is created and you don't modify your own container.
Nevertheless my method doesn't work fine and I appreciate your help and will
rework my method. I'll have a look at your pseudo code and think a bit how I
can rework both copy methods.
Regards,
Markus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20110409/17d5bf5a/attachment-0001.htm>
More information about the LibreOffice
mailing list