Hi,
I want to export selected object to PNG file. I prepared macro, but it is not working as I want to. It is exporting whole first page instead selected object.
Please help me to modify macro to export only selected object.
Thank you
Here is code:
Sub SaveSelectedObjectAsJPG()
Dim oDoc As Object
Dim oSelection As Object
Dim oExporter As Object
Dim oFilterData(3) As New com.sun.star.beans.PropertyValue
Dim sFileName As String
oDoc = ThisComponent
oSelection = oDoc.CurrentSelection
If oSelection.Count = 0 Then
MsgBox "No object selected.", 16, "Error"
Exit Sub
End If
sFileName = "E:\Project\!TEST.jpg"
oFilterData(0).Name = "PixelWidth"
oFilterData(0).Value = 1024 ' Change this to your desired width
oFilterData(1).Name = "PixelHeight"
oFilterData(1).Value = 768 ' Change this to your desired height
oFilterData(2).Name = "FilterName"
oFilterData(2).Value = "draw_jpg_Export"
oFilterData(3).Name = "SelectionOnly"
oFilterData(3).Value = True
oExporter = createUnoService("com.sun.star.drawing.GraphicExportFilter")
oExporter.setSourceDocument(oSelection(0))
oExporter.filter(oFilterData())
oDoc.storeToURL(ConvertToURL(sFileName), oFilterData())
MsgBox "Object saved as JPG.", 64, "Success"
End Sub