Mir diesem Makro füge ich an eine bestimmte Stelle in der Tabelle ein Bild ein.
Aber ich bekomme an der Stelle "Point.x = aPos.x - 2700" immer den Fehler "Basic Laufzeitfehler, Variable nicht belegt."
Code: Alles auswählen
Public Point
Sub GrafikEinfuegen
rem----------------------------------------------------------------------------------------------------------S&W Logo
mycell = oSheet.getCellByPosition(Letztespalte,0)
oColumn = mycell.getColumns.getByIndex(0).getName()
cellname = oColumn
cellname = cellname & 1
oCell = oDoc.sheets.getByName("Standortliste").getCellRangeByName(cellname)
aPos = oCell.Position
MsgBox aPos.x 'Zeigt 33973 Ist zum Testen
MsgBox aPos.y 'Zeigt 0 Ist zum Testen
Point.x = aPos.x-2700
Point.y = aPos.y
Size.Width = 5450
Size.Height = 2000
Page = oDoc.drawPages(0)
GraphicObjectShape = oDoc.createInstance("com.sun.star.drawing.GraphicObjectShape")
GraphicObjectShape.Size = Size
GraphicObjectShape.Position = Point
If OS = 1 Then 'Windows
sURL = "file:///Z:/Programme/Vorlagen für Makros/Angebote/Bilder/Klein/SW.jpg"
GraphicObjectShape.GraphicURL = sURL
ElseIf OS = 4 Then 'Unix
sURL = "file:///media/transfer/Programme/Vorlagen für Makros/Angebote/Bilder/Klein/SW.jpg"
GraphicObjectShape.GraphicURL = sURL
End IF
oBitmaps = oDoc.createInstance("com.sun.star.drawing.BitmapTable")
sInternalPicName = "myPic"
For i = 0 To 200
sInternalPicName = "myPic" & i
If NOT oBitmaps.hasByName(sInternalPicName) Then Exit For
Next i
oBitmaps.insertByName(sInternalPicName, sURL )
If NOT oBitmaps.hasByName(sInternalPicName) Then
MsgBox("Ausgewählte Datei konnte nicht als Grafik eingefügt werden",48,"Fehler")
Exit Sub
End If
sURL = oBitmaps.getByName(sInternalPicName)
GraphicObjectShape.Name = "S&W"
GraphicObjectShape.Title = "S&W"
GraphicObjectShape.GraphicColorMode = com.sun.star.drawing.ColorMode.STANDARD
Page.add(GraphicObjectShape)
GraphicObjectShape.GraphicURL = sURL
rem----------------------------------------------------------------------------------------------------------Ende
End Sub