Advertisement
Guest User

Untitled

a guest
May 18th, 2018
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Sub Main
  2.     'Declare all needed variables
  3.     Dim s, cs, y, w
  4.    
  5.     'Get all document's sheets
  6.     s = ThisComponent.Sheets
  7.    
  8.     'Walk over all document's sheets
  9.     For i = 0 To s.getCount()-1
  10.         'Get the current sheet (cs stands for CurrentSheet)
  11.         cs = s.getByIndex(i)
  12.        
  13.         'Get the year cell (here B5 cell)
  14.         y = cs.getCellRangeByName("B5") 'Change here with year cell name
  15.        
  16.         'Get the week cell (here B6 cell)
  17.         w = cs.getCellRangeByName("B6").String 'Change here with month cell name
  18.         'If week number is lower than 10 add a leading "0" char
  19.         If CInt(w) < 10 Then
  20.             w = "0" & w
  21.         End If
  22.        
  23.         'Change the current sheet's name with "yyyy-ww"
  24.         cs.Name = y.String & "-" & w
  25.     Next i
  26. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement