OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

check if sheet exists

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
daniel2003
Newbie
Newbie


Joined: 23 Oct 2003
Posts: 4

PostPosted: Fri Oct 31, 2003 12:59 am    Post subject: check if sheet exists Reply with quote

hello,

how can i check if a sheet exists in the openoffice calc?

in vba i write

if sheets("blabla").activate = true
msgbox("exist")
else
msgbox("not exist")
end if


thanks

daniel
Back to top
View user's profile Send private message
DannyB
Moderator
Moderator


Joined: 02 Apr 2003
Posts: 3991
Location: Lawrence, Kansas, USA

PostPosted: Fri Oct 31, 2003 8:52 am    Post subject: Reply with quote

Can you use getByName() or hasByName()?

getByName() would return the sheet.

hasByName() would return a true/false whether the sheet is present in the collection.

Code:
   oCalcDoc = ThisComponent
   oSheets = oCalcDoc.getSheets()
   
   If oSheets.hasByName( "Sheet2" ) Then
      MsgBox( "This spreadsheet DOES have a sheet named Sheet2." )
   EndIf
   
   If oSheets.hasByName( "MeowMix" ) Then
      MsgBox( "This spreadsheet DOES have a sheet named MeowMix." )
   EndIf
   
   oSheet = oSheets.getByName( "Sheet2" )
   ' Change cell B2
   oSheet.getCellByPosition( 1, 1 ).setFormula( "July" )
   ' Change cell C2
   oSheet.getCellByPosition( 2, 1 ).setValue( 2856 )

_________________
Want to make OOo Drawings like the colored flower design to the left?
Back to top
View user's profile Send private message
daniel2003
Newbie
Newbie


Joined: 23 Oct 2003
Posts: 4

PostPosted: Tue Nov 04, 2003 3:49 am    Post subject: Reply with quote

Hello,

thanks


daniel
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group