如何使vba代码与libre office兼容

编程入门 行业动态 更新时间:2024-10-23 17:35:10
本文介绍了如何使vba代码与libre office兼容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我最近从Windows迁移到pclinuxos,似乎喜欢它。我唯一遇到的问题是libreoffice,默认的电子表格包与excel宏不兼容。以下是vba代码:

Option VBASupport Sub DeleteToLeft() Selection.SpecialCells xlBlanks)。删除shift:= xlToLeft End Sub 函数SinceLastWash() Application.Volatile WashCount = 0 WearCount = 0 CurrentRow =应用程序.ThisCell.Row 对于i = 3到35 如果范围(Cells(CurrentRow,i),Cells(CurrentRow,i))。Value =a然后 WearCount = WearCount + 1 End If 如果Range(Cells(CurrentRow,i),Cells(CurrentRow,i))。Value =q然后 WashCount = WashCount + 1 WearCount = 0 End If Next i SinceLastWash = WearCount 结束函数函数testhis() testhis = Application.ThisCell.Row 结束函数

有没有办法转换这个代码,使其与libreoffice兼容,或者我必须学习一个全新的语言像python?学习python不会是一个问题,但不是我的问题的解决方案,因为我有许多与excel相关的文件有很多vba代码,我不可能在工作中使用open office / libreoffice ...

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

感谢

解决方案

从 LibreOffice的在线帮助文​​件:

除了一些例外,Microsoft Office和LibreOffice无法运行相同的宏代码。 Microsoft Office使用VBA(Visual Basic for Applications)代码,LibreOffice使用基于LibreOffice API(应用程序接口)环境的基本代码。虽然编程语言是一样的,但是对象和方法是不同的。

如果您在LibreOffice中启用了此功能,LibreOffice的最新版本可以运行某些Excel Visual Basic脚本 - PreferencesTools - 选项 - 加载/保存 - VBA属性。

在现实中,你很可能需要坐下来 LibreOffice API 并重写功能。

I have recently migrated to pclinuxos from windows and seem to like it. The only problem I am facing is that libreoffice, the default spreadsheet package is not compatible with excel macros. Below is the vba code I have:

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

Is there a way to convert this code to make it compatible with libreoffice or do I have to learn an altogether new language like python? Learning python would not be a problem but is not a solution to my problem as I have many work related files in excel which have a lot of vba code and it is not possible for me to use open office/libreoffice at work...

I just want to add that the function SinceLastWash gives the correct value in some cells where I use it and in others gives an error, #NAME?

Thanks

解决方案

From 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.

In reality, you would most likely need to sit down with the LibreOffice API and rewrite the functionality.

更多推荐

如何使vba代码与libre office兼容

本文发布于:2023-10-13 10:24:38,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1487693.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:代码   vba   office   libre

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!