I was using windows and migrated to Ubuntu. Now i want to use macros of excel in open office spreadsheet but I could not use. The macro was written in VbScript. Can anyone help me to resolve this problem. I have attached the code for reference.
Thank you
Code: Select all
Rem Attribute VBA_ModuleType=VBAModule
Option VBASupport 1
Sub Button1_Click()
Dim objExcl As Worksheet
Dim i As Integer
Dim strRow, hasPrevTab As Integer
Dim curDate, prevDate, LastSheet As String
hasPrevTab = 0 'initialize variable
'get name format for tabs
curDate = getMonthName(month(Date)): curDate = curDate & " - " & Year(Date)
If month(Date) <> 1 Then
prevDate = getMonthName(month(Date) - 1) & " - " & Year(Date)
Else
prevDate = getMonthName(12) & " - " & Year(Date) - 1
End If
'check for new tab added for current month
For stCount = 1 To Sheets.Count
LastSheet = Sheets(stCount).Name
If UCase(Sheets(stCount).Name) = UCase(curDate) Then
hasPrevTab = 2
Exit For
End If
Next stCount
If hasPrevTab = 0 Then
If Sheets(LastSheet).Select = True Then
Sheets(LastSheet).Select
Sheets(LastSheet).Copy After:=Sheets(LastSheet)
Sheets(LastSheet & " (2)").Select
Sheets(LastSheet & " (2)").Name = curDate
End If
hasPrevTab = 1
End If
If hasPrevTab = 2 Then
hasPrevTab = MsgBox("Refresh this file?" & vbCrLf & vbCrLf & _
"Refreshing this file will Clear all the content." & vbCrLf & _
"Are you sure?", vbOKCancel, "File Refresh")
End If
If hasPrevTab = 1 Then
'Review Date and Done by
Range("B5:B6").Select
Selection.ClearContents
'rundate
Range("B11:C11").Select
Selection.ClearContents
'OAM comment
Range("C14:C14").Select
Selection.ClearContents
'Import data and review sheet
Range("C18:F34").Select
Selection.ClearContents
'RM Check
Range("B37:E39").Select
Selection.ClearContents
'DATA check
Range("C43:D51").Select
Selection.ClearContents
'Rules table
Range("B55:C150").Select
Selection.ClearContents
End If
Range("A1").Select
End Sub
Function getMonthName(month)
Dim monthName As String
Select Case month
Case 1
monthName = "Jan"
Case 2
monthName = "Feb"
Case 3
monthName = "Mar"
Case 4
monthName = "Apr"
Case 5
monthName = "May"
Case 6
monthName = "Jun"
Case 7
monthName = "Jul"
Case 8
monthName = "Aug"
Case 9
monthName = "Sep"
Case 10
monthName = "Oct"
Case 11
monthName = "Nov"
Case 12
monthName = "Dec"
Case Else
monthName = "Err"
End Select
getMonthName = monthName
End Function