Gostaria de ajuda com essa macro. Esta dando erro na linha:
oDrawPage = oDoc.getSheets().getByName(“Planilha1”).getDrawPage()
Segue macro:
Sub AddImg
Dim GraphicObjectShape As Object
Dim Point As New com.sun.star.awt.Point
Dim Size As New com.sun.star.awt.Size
Dim Page As Object
Dim oImg as String
oDoc = ThisComponent
Page = oDoc.DrawPages(0) 'Posição da planilha no seu arquivo. Planilha1 = 0
oPlan = oDoc.Sheets.getByName("Planilha1")
'Pode ser utilizado qualquer uma das duas linhas abaixo. Para trocar, retire o apostrofe (') da linha de códido a frente
'Caso escolha colocar o link de acesso da imagem aqui dentro, é necessário alterar o endereço
'oImg = oPlan.getCellRangeByName("A1").String 'Aqui pega o link da célula
oImg = "C:\MC\" & oPlan.getCellRangeByName("A1").String & ".jpg" 'Aqui pega o nome da célula
Call DeletaImg
Point.x = 1000 'Posição X da planilha
Point.y = 1000 'Posição Y da planilha
Size.Width = 2000 'Largura da imagem
Size.Height = 2000 'Altura da imagem
GraphicObjectShape = oDoc.createInstance("com.sun.star.drawing.GraphicObjectShape")
GraphicObjectShape.Size = Size
GraphicObjectShape.Position = Point
GraphicObjectShape.GraphicURL = ConvertToUrl(oImg)
Page.add(GraphicObjectShape)
End Sub
Sub DeletaImg()
'Fonte: https://stackoverflow.com/questions/46048667/how-to-delete-all-images-from-all-sheets-of-a-libreoffice-calc-workbook
Dim oDrawPage As Object
Dim oShape As Object
oDrawPage = oDoc.getSheets().getByName("Planilha1").getDrawPage()
oShape = oDrawPage.getByIndex(1) 'sempre será a última imagem
oDrawPage.remove(oShape)
End Sub