Hello!
We're trying to insert a picture in a Word file. I've tried to first insert a textbox and then set the textbox's backround image to this image we want to insert, and I've also tried to just insert it as an image (without the textbox). In both ways, you could specify the width and the height. The picture is 130 x 130 px. When we pre open the picture and when we insert it directly in Word, the size remains the same. BUT! When we insert it in the document in code, the image size gets a little bit larger for somehow..
Here's what I do:
Public Sub drawBlueAGLogo(document As Document, premie As String)
Dim pImgAGCirkel = document.Sections(0).AddParagraph.AppendTextBox(130, 130)
Dim pPremieStor = pImgAGCirkel.Body.AddParagraph
Dim pPremieLiten = pImgAGCirkel.Body.AddParagraph()
formatText(pPremieStor, vbNewLine & vbNewLine & Math.Round(premie / 12), "Calibri", 30, False, Color.White) <-- this is just a function that formats the text
pPremieStor.Format.HorizontalAlignment = HorizontalAlignment.Center
formatText(pPremieLiten, "kr/månaden" & vbNewLine & "med autogiro", "Calibri", 11, False, Color.White)
pPremieLiten.Format.HorizontalAlignment = HorizontalAlignment.Center
pImgAGCirkel.Format.HorizontalOrigin = HorizontalOrigin.Page
pImgAGCirkel.Format.HorizontalPosition = 215
pImgAGCirkel.Format.VerticalOrigin = VerticalOrigin.Page
pImgAGCirkel.Format.VerticalPosition = 40
pImgAGCirkel.Format.FillEfects.Type = BackgroundType.Picture
pImgAGCirkel.Format.FillEfects.Picture = Image.FromFile("test.png")
pImgAGCirkel.Format.TextWrappingStyle = TextWrappingStyle.Through
pImgAGCirkel.Format.NoLine = True
End Sub
I've also tried to set the size as a float (130.0F x 130.0F). Am I doing somehting wrong here?
As you can see, I've attached the two images before and after inserting it into our code.
Best,
Elin