When I open an excel file with pictures, most often than not, their proportion rate is off. I have to set them back to their original size and then resize manually.
I’d like to do it automatically with a macro but I can’t find a way to get the original size of each picture.
I googled it and found the “ActualSize” property but it isn’t working for me. I can only get the Size. And I have no idea how the LibreOffice docs work.
This is the code I’m writing. I don’t have experience with LibreOffice Basic, but I’ve written VBS before.
Sub ResizePics()
dim oDoc As Object
oDoc = ThisComponent
for iSheet = 0 To oDoc.getSheets().getCount() - 1
dim oDrawPage As Object
oDrawPage = oDoc.getSheets().getByIndex(iSheet).getDrawPage()
dim img as Object
for i=0 to oDrawPage.getCount() -1
img = oDrawPage.getByIndex(i)
MsgBox( img.ActualSize.Height )
'Dim aNewSize As New com.sun.star.awt.Size
'aNewSize.Width = 10000
'aNewSize.Height = 10000
'img.setSize(aNewSize)
Next i
Next iSheet
End Sub
This code is unfinished, I’m just trying to get the original size first, then the rest should be pretty straight with setSize. Is there any other way to get the original size, or why is the ActualSize not working for me ?
Using LibreOffice Calc 6.0.1.1
Thanks