我最近从 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/