Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how can i import a vb.net graphic in a word document

Status
Not open for further replies.

randmeer

Technical User
Nov 1, 2005
7
NL
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 ?

Thank you in advance
 
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)

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Thanks a lot ThatRickGuy,

I managed in this way to import a graphic in my Word document :)
 
This way:

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

Jaap
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top