Hi
I have created a grapic in VB.net on a panel. (panel.paint / e.graphics.drawline… etc.).
How can I import this grapic in a Word document that I am creating with VB.net ?
The easiest way would be to just hit alt-print screen (while that window has focus) then jump to word and hit ctrl-v.
A more automated method would be to save the image to bitmap (either through the use of a picture box or bitblt) then inserting the image into word (not sure if that can be automated)
Public Sub MakeBitmap()
Dim newBitmap As Bitmap = New Bitmap(400, 400, Imaging.PixelFormat.Format32bppArgb)
Dim BrdsGraphic As Graphics = Graphics.FromImage(newBitmap)
Dim Pen As New Pen(Color.White, 1)
Dim Pnt1 as point
Dim Pnt2 as point
p1.X = 10
p1.Y = 10
p2.X = 100
p2.Y = 100
BrdsGraphic.DrawLine(Pen, Pnt1,Pnt2)
newBitmap.Save("c:\temp\TestImage.jpg", Imaging.ImageFormat.Jpeg)
End Sub
Public Sub WriteBitmap()
Dim wrd As Word.Application
wrd = New Word.Application
wrd.Visible = True
Dim doc As Word.Document = wrd.Documents.Add()
doc.Shapes.AddPicture("c:\temp\TestImage.jpg")
doc.Close(SaveChanges:=False)
wrd.Quit()
wrd = Nothing
End Sub
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.