环顾四周,找不到它。需要一个宏,以便我可以在695个不同的文件上重复695次。文档有些不安,或者我不走运。
我可以在Microsoft VBA中执行以下操作:
Sub VbaBlackies
Dim oSl As Slide
For Each oSl In ActivePresentation.Slides
With oSl
.FollowMasterBackground = msoFalse
.DisplayMasterShapes = msoFalse
With .background
.Fill.ForeColor.RGB = RGB(0, 0, 0)
.Fill.BackColor.RGB = RGB(0, 0, 0)
End With
End With
Next oSl
End Sub
我在LibreOffice BASIC中寻找类似的东西。我可以这样开始使用代码:
Sub Main
Dim oDoc As Object
Dim oDPages As Object
Dim oDPage As Object
oDoc= ThisComponent
oDPages = oDoc.getDrawPAges()
For i=0 To oDPages.count()-1
oDPage = oDPages.getByIndex(i)
oDPage.Background = RGB(0,0,0) 'This does not work.
'I have no idea on how to access the object's properties and alter them.
Next i
End Sub
请问任何想法?
答案 0 :(得分:1)
您正在寻找的是Andrew Pitonyak's macro document的清单15.1,这是宏编程的基本参考。
Sub ChangeBackground
Dim oDoc as Object
oDoc = ThisComponent
Dim oDrawPages as Object, oDrawPage as Object
oDrawPages = oDoc.getDrawPages()
oDrawPage = oDrawPages.getByIndex(0)
Dim oBackground as Object
oBackground = oDoc.createInstance("com.sun.star.drawing.Background")
oBackground.FillColor = RGB(250,0,0)
oDrawPage.Background = oBackground
End Sub
API文档位于https://www.openoffice.org/api/docs/common/ref/com/sun/star/drawing/Background.html。
答案 1 :(得分:1)
YES!工作就像一个魅力,非常感谢答案!
这是为我制定的最终代码:
Sub Main
Dim oDoc As Object
Dim oDPages As Object
Dim oDPage As Object
oDoc = ThisComponent
oDPages = oDoc.getDrawPAges()
For i=0 To oDPages.count()-1
oDPage = oDPages.getByIndex(i)
Dim oBackground As Object
oBackground = oDoc.createInstance("com.sun.star.drawing.Background")
oBackground.FillColor = RGB(0,0,0)
oDPage.Background = oBackground
Next i
End Sub