How to convert file excel *xlsm to OO *ods

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
eriz
Posts: 1
Joined: Sat Sep 08, 2018 3:30 am

How to convert file excel *xlsm to OO *ods

Post by eriz »

Hi, dear..
I had created a program form searching use vba maro in excel, and that is work.
Than i was try open in OO calc. and save as to *ods. But isn't working... Any problems for writing code macro in oo. maybe not same.
Can u help me Please....!!!
Exampel 1. = this fungtions for hide button close in form (code macro in excel)

Code: Select all

Rem Attribute VBA_ModuleType=VBAModule
Option VBASupport 1
Option Explicit
Private Const MF_BYPOSITION = &H400
Private Const MF_REMOVE = &H1000
Private Const WS_SYSMENU = &H80000
Private Const GWL_STYLE = (-16)
Private hwnd As Long
Private lStyle As Long

#If VBA7 And Win64 Then
Private Declare PtrSafe Function FindWindow Lib "user32" _
        Alias "FindWindowA" (ByVal lpClassName As String, _
        ByVal lpWindowName As String) As LongLong
Private Declare PtrSafe Function GetWindowLong Lib "user32" _
        Alias "GetWindowLongA" (ByVal hwnd As Long, _
        ByVal nIndex As Long) As LongLong
Private Declare PtrSafe Function SetWindowLong Lib "user32" _
        Alias "SetWindowLongA" (ByVal hwnd As Long, _
        ByVal nIndex As Long, _
        ByVal dwNewLong As Long) As LongLong
Private Declare PtrSafe Function DrawMenuBar Lib "user32" _
        (ByVal hwnd As Long) As LongLong
Private Declare PtrSafe Function GetMenuItemCount Lib "user32" _
                (ByVal hMenu As Long) As LongLong
Private Declare PtrSafe Function GetSystemMenu Lib "user32" _
                (ByVal hwnd As Long, _
                ByVal bRevert As Long) As LongLong
Private Declare PtrSafe Function RemoveMenu Lib "user32" _
                (ByVal hMenu As Long, ByVal nPosition As Long, _
                ByVal wFlags As Long) As LongLong
#Else
Private Declare Function FindWindow Lib "user32" _
                Alias "FindWindowA" _
                (ByVal lpClassName As String, _
                ByVal lpWindowName As String) As Long
Private Declare Function GetWindowLong Lib "user32" _
                Alias "GetWindowLongA" _
                (ByVal hwnd As Long, _
                ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" _
                Alias "SetWindowLongA" _
                (ByVal hwnd As Long, _
                ByVal nIndex As Long, _
                ByVal dwNewLong As Long) As Long
Private Declare Function DrawMenuBar Lib "user32" _
                (ByVal hwnd As Long) As Long
Private Declare Function GetMenuItemCount Lib "user32" _
                (ByVal hMenu As Long) As Long
Private Declare Function GetSystemMenu Lib "user32" _
                (ByVal hwnd As Long, ByVal bRevert As Long) As Long
Private Declare Function RemoveMenu Lib "user32" _
                (ByVal hMenu As Long, ByVal nPosition As Long, _
                ByVal wFlags As Long) As Long
#End If

Sub HideXCloseButton(oForm As Object)
hwnd = FindWindow("ThunderDFrame", oForm.Caption)
lStyle = GetWindowLong(hwnd, GWL_STYLE)
SetWindowLong hwnd, GWL_STYLE, lStyle And Not WS_SYSMENU
End Sub
Example 2 = LBRESULT.ColumnCount = ThisWorkbook.Sheets("Tabel").[A1].CurrentRegion.Columns.Count (error)

Code: Select all

Private Sub UserForm_Activate()
    hide_sheet
    LBRESULT.ColumnCount = ThisWorkbook.Sheets("Tabel").[A1].CurrentRegion.Columns.Count

    LBRESULT.ColumnWidths = "120;150;150;150;50;350;400;100"
     
    Set RangeTabel = ThisWorkbook.Sheets("Tabel").[A1].CurrentRegion
  
    Set RangeCopyTo = ThisWorkbook.Sheets("Dummy").[G1]
   
    Set RangeKriteria = ThisWorkbook.Sheets("Dummy").[A1:A2]
   
End Sub
Example 3 = Combo Box not showing

Code: Select all

Private Sub UserForm_Initialize()

With inisial
    .AddItem "Nama Anggota"
    .AddItem "Nama Pemilik Sertifikat"
    .AddItem "Alamat Sertifikat"
    .AddItem "Alamat Fisik"
End With
End Sub
thx u
Attachments
form searching.ods
(25.28 KiB) Downloaded 126 times
OpenOffice ver 4.1.5 and OS win 7
User avatar
Zizi64
Volunteer
Posts: 11353
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: How to convert file excel *xlsm to OO *ods

Post by Zizi64 »

The MS VBA and the AOO/LO API are not compatible. API: Application Programming Interface) You must rewrite all of your macros based on the API functions - if you are using them in the .ods file format. (Then they will not work in Excel!)

Or you can try your VBA macros in the LibreOffice. It has a littlebit higher compatibility with the foreign fileformats and the VBA macros.
Note: there is not (never was and never will be) 100% compatibility between the different fileformats and between the different programming environments.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
Post Reply