Ask Your Question
0

Sheet name vs. sheet index

asked 2012-04-23 22:59:56 +0200

Max74 gravatar image Max74
1 1 1

Hi there,

I need a macro that check if a sheet exists by its index instead of its name

For example:

oSheets = ThisComponent.Sheets()

If oSheets.hasByName("Invoice") Then

[...]

works fine

Instead I need something like this (that obviously doesn't work):

If oSheets.hasByIndex(2) Then

[...]

Anyone can help me?

Thanks.

delete close flag offensive retag edit

1 Answer

Sort by » oldest newest most voted
1

answered 2012-04-25 17:36:02 +0200

w_whalley gravatar image w_whalley flag of United States
1591 10 24

updated 2012-04-25 17:57:19 +0200

Sub Main
target=2 rem looking for sheet number 2 (not sheet index 2)
oSheets=ThisComponent.Sheets()
i=oSheets.getcount() rem i is the number of sheets
if (i >= target) then
   msgbox "Found it"
else
   msgbox "Not found"
end if   
End Sub
link delete flag offensive edit

Comments

@Max74, Did @w_whalley's answer work for you? Please let us know so we can resolve this question.

qubit ( 2013-01-27 07:12:09 +0200 )edit

Login/Signup to Answer

Donate

LibreOffice is made available by volunteers around the globe, backed by a charitable Foundation. Please support our efforts: Your donation helps us to deliver a better product!

Question tools

Follow

subscribe to rss feed

Stats

Asked: 2012-04-23 22:59:56 +0200

Seen: 363 times

Last updated: Apr 25 '12