It used to be so easy by using this line:
oPageStyle.BackGraphicURL=imgurl
but it became deprecated with LibreOffice 6.1.
Now I am trying this code, and it runs without error but does not set the background image:
imgurl="file:///C:/Users/fodor/OneDrive/Documents/Recipe%20organizer/Developing-own/Big%20Images/20180319_114502.jpg"
oPageStyle = ThisComponent.getStyleFamilies().getByName("PageStyles").getByName("Default Style")
oPageStyle.FillColor = RGB(255,255,255)
oPageStyle.BackGraphicLocation = com.sun.star.style.GraphicLocation.LEFT_TOP
oProvider = createUnoService("com.sun.star.graphic.GraphicProvider")
Dim args(0) as new com.sun.star.beans.PropertyValue
args(0).Name = "URL"
args(0).Value = imgurl
oPageStyle.BackGraphic = oProvider.queryGraphic(args())
Testing in the end:
MsgBox isNull(oProvider.queryGraphic(args())) 'False
MsgBox isNull(oPageStyle.BackGraphic) 'True