Using macro written in VbScript of excel in linux platform

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
bharatsatyal
Posts: 2
Joined: Wed Feb 11, 2009 5:57 am

Using macro written in VbScript of excel in linux platform

Post by bharatsatyal »

Hi,
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


OOo 2.4.X on Ubuntu 8.x
FJCC
Moderator
Posts: 9274
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Using macro written in VbScript of excel in linux platform

Post by FJCC »

VB macros cannot be imported into OpenOffice.org. OOo has its own Basic language and API. I don't know of any way to automatically translate a VB macro. You can get documentation on OOo macros at www.openoffice.org under the "I need help with my OpenOffice.org" and the Documentation Project. Andrew Pitonyak has some very helpful documents at this location. This forum is also a good place for information. You will have to be willing to dedicate a substantial effort to making the switch.
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
Post Reply