大家早上好,我想构建一个Uno Basic宏,它允许我们设置一个单元格的格式,这样就可以先用一个字符格式化内容,然后再用另一个字符进行格式化。我需要它能够产生标签,然后使用串行打印与作家打印。
这是我的密码:
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)。但是,由于铭文是用字体制作的,而BarCode使用的是另一种字体,所以现在我想在最后一个单元格中写入所有内容,然后序列化打印。你能帮我吗?我感谢你。
发布于 2022-06-29 13:33:06
这是我的测试代码,很好用。
Private Sub TEST()
Dim Doc As Object
Dim Sheet As Object
Dim Cell As Object
Dim oCurs as Object
Doc = ThisComponent
'Sheet = Doc.Sheets(0)
sheet = ThisComponent.Sheets.getByName("Test") 'Select the sheet by name
ThisComponent.CurrentController.setActiveSheet(sheet) 'Activate the sheet
Cell = Sheet.getCellRangeByName("F18") 'Select the cell for Test
oCurs = Cell.createTextCursor()
oCurs.gotoStart(False)
oCurs.CharFontName = "Gill Sans MT" 'Set Property Style Font 1
oCurs.CharHeight = 10 'Set Property for Char Size
oCurs.getText().insertString(oCurs, "Inv. 13916" & vbcrlf, True) 'Insert and select
oCurs.goRight(0, False) 'De-select text
oCurs.CharFontName = "Libre Barcode 128" 'Set Property Style Font 2
oCurs.CharHeight = 48 'Set Property for Char Size
oCurs.getText().insertString(oCurs, BARCODE128_ENCODED("13916"), True) 'Insert and select second text with Code128 Algoritm
oCurs.goRight(0, False) 'De-select text
Cell.HoriJustify = com.sun.star.table.CellHoriJustify.CENTER
Cell.VertJustify = com.sun.star.table.CellVertJustify.CENTER
End Sub
https://stackoverflow.com/questions/72773932
复制相似问题