Thanks JohnSUN… 3 Thinks… Your right …to correct my Doubts…
-
For Long Days i have One Doubt , When ever I posting Code either its Small or Big… My Code Won’t Show Proper Way… Now, I Understand what i made mistake … and As Per Your Screen Shots I Follow up … Thanks…for that because, Without Asking this Doubt … Your Clearing that one…
-
Deleting Sheets , Your Code ( For = i Sheet.getCout()-1 To 0 Step -1 ) Working… thanks…
for Clearing my Doubts.
-
Deleting Sheets, Using @karolus Python Code into STAR BASIC Code… You Clearing My Doubts… and I Correct my Code …yes, Its Work…Thanks…
I will Post The Two Codes… and Close this Topic As Solution
Thanks To @JohnSun & @karolus …All the Credits goes to them… regarding this Topic Solution
Here is the Solution Code
Using For … Next Loop
Private Sub Deleting_Sheets
Dim Doc As Object, Sheets As Object, Sheet As Object
Dim sheetName As String
Dim i As Long
Doc = ThisComponent
Sheets = Doc.getSheets()
For i = Sheets.getCount()-1 To 0 Step -1
Sheet = Sheets.getByIndex(i)
sheetName = Sheet.Name
IF sheetName <> "Sheet1" Then
Sheets.removeByName(sheetName)
End IF
Next
End Sub
- Using For Each… Loop Using Sheet.ElementNames
===========================================
Private Sub Deleting_Sheets
Dim Doc As Object, Sheets As Object, Sheet As String
Dim sheetName As String
Doc = ThisComponent
Sheets = Doc.Sheets
sheetName = "Sheet1"
For Each Sheet In Sheets.ElementNames
IF Sheet <> sheetName Then
Sheets.removeByName(Sheet)
End IF
Next
End Sub
Here, is the macro containing sheet with code
Deleting_Sheets_macros.ods (11.8 KB)