excel - 如何使 vba 代码与 libre office 兼容

标签 excel vba openoffice.org libreoffice

我最近从 Windows 迁移到了 pclinuxos,并且似乎很喜欢它。我面临的唯一问题是 libreoffice(默认电子表格包)与 Excel 宏不兼容。下面是我的vba代码:

Option VBASupport 
Sub DeleteToLeft()
    Selection.SpecialCells(xlBlanks).Delete shift:=xlToLeft
End Sub
Function SinceLastWash()
    Application.Volatile
    WashCount = 0
    WearCount = 0
    CurrentRow = Application.ThisCell.Row
    For i = 3 To 35
        If Range(Cells(CurrentRow, i), Cells(CurrentRow, i)).Value = "a" Then
            WearCount = WearCount + 1
        End If
        If Range(Cells(CurrentRow, i), Cells(CurrentRow, i)).Value = "q" Then
            WashCount = WashCount + 1
            WearCount = 0
        End If
    Next i
    SinceLastWash = WearCount
End Function
Function testhis()
testhis = Application.ThisCell.Row
End Function

有没有办法转换此代码以使其与 libreoffice 兼容,或者我是否必须学习一种全新的语言,例如 python?学习python不会成为问题,但不能解决我的问题,因为我在excel中有很多与工作相关的文件,其中有很多vba代码,而且我不可能在工作中使用open office/libreoffice...

我只想补充一点,SinceLastWash 函数在我使用它的某些单元格中给出了正确的值,而在其他单元格中给出了错误,#NAME?

谢谢

最佳答案

来自LibreOffice's online help file:

With a few exceptions, Microsoft Office and LibreOffice cannot run the same macro code. Microsoft Office uses VBA (Visual Basic for Applications) code, and LibreOffice uses Basic code based on the LibreOffice API (Application Program Interface) environment. Although the programming language is the same, the objects and methods are different.

The most recent versions of LibreOffice can run some Excel Visual Basic scripts if you enable this feature at LibreOffice - PreferencesTools - Options - Load/Save - VBA Properties.

实际上,您很可能需要坐下来与 the LibreOffice API 交谈。并重写功能。

关于excel - 如何使 vba 代码与 libre office 兼容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24724050/

相关文章:

excel - 在 VBA Excel 中传递范围对象

vba - VBA 中的构造函数 - 运行时错误 91 "Object variable not set"

javascript - 一次将多个数据集导出到Excel()

Python-UNO桥: change PDF export options

openoffice.org - 插入 HTML Libre Office

vba - 从最后一行复制选择

c# - 创建供 Excel 和 C# 使用的 C++ .dll(32/64 位窗口)

excel - 宏是否有可能损坏文件?

VBA 不根据其树结构读取 XMLHTTP 请求的响应

java - 连接到 OpenOffice.org 时连接失败