libreoffice calc宏 - 在同一单元格内设置两种不同类型的字体
大家早上好, 我想构建一个基本宏,使我们能够以首先使用一个字符格式化的内容设置一个格式化一个单元格,然后使用其他字符。 我需要它能够产生标签,然后使用串行打印与作家打印。
这是我的代码:
Public Sub FormattaCarattere()
Dim Doc As Object
Dim Sheet As Object
Dim Cell As Object
Doc = ThisComponent
sheet = ThisComponent.Sheets.getByName("Test")
ThisComponent.CurrentController.setActiveSheet(sheet)
Cell = Sheet.getCellRangeByName("D7")
Cell.CharFontName = "Gill Sans MT"
Cell.String = "TEST-01" & vbcrlf 'Insert one Carriege Return
Cell.CharFontName = "Libre Barcode 128 Text" 'I want to change font in the same cell
Cell.String = Cell.String & "TEST-02"
Cell.HoriJustify = com.sun.star.table.CellHoriJustify.CENTER
Cell.VertJustify = com.sun.star.table.CellVertJustify.CENTER
End Sub
下面是我想做的事情的图像:
我已经编写了一些宏来生成正确单元格中的标题,并生成相对条形码( Code128)正确。但是,由于在条形码使用另一种时,用字体制作了铭文,因此现在我想在最终单元格中写下所有内容,然后序列化打印。 你可以帮我吗? 我感谢。
Good morning everyone,
I would like to build a Uno Basic macro that allows us to set the formatting one cell in such a way as to have the content first formatted with one character and then subsequently with a different character.
I would need it to be able to produce labels to then print with the Writer using serial printing.
This is my code:
Public Sub FormattaCarattere()
Dim Doc As Object
Dim Sheet As Object
Dim Cell As Object
Doc = ThisComponent
sheet = ThisComponent.Sheets.getByName("Test")
ThisComponent.CurrentController.setActiveSheet(sheet)
Cell = Sheet.getCellRangeByName("D7")
Cell.CharFontName = "Gill Sans MT"
Cell.String = "TEST-01" & vbcrlf 'Insert one Carriege Return
Cell.CharFontName = "Libre Barcode 128 Text" 'I want to change font in the same cell
Cell.String = Cell.String & "TEST-02"
Cell.HoriJustify = com.sun.star.table.CellHoriJustify.CENTER
Cell.VertJustify = com.sun.star.table.CellVertJustify.CENTER
End Sub
This below the image of what I would like to be able to do:
I have already written some macroes that generate the header in the correct cells and that generate the relative Bar Code (Code128) correctly. But since an inscription is made with a font while the BarCode uses another one, now I would like to write everything in a final cell and then serialize the print.
You can help me ?
I thank.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
创建一个文本光标以修改单元格内的文本。
Create a text cursor to modify the text inside the cell.
这是我的测试代码,工作正常。
This is my code for a test and it's work fine.