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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Save a PicBox image as a word document? 2

Status
Not open for further replies.

tommy19

Programmer
Aug 23, 2001
49
US
Howdy,

I am wondering if this is even a possibility. I am trying to print invoices into a Word Doc from VB. I have a config file that holds the location on the page and font characteristics to print a string and a data file which holds the string. I am writing to a picbox with the Print statement and Printing the Image from the Printer object. The need has arrived to save them as a Word file. Is there a way to save a picbox image as a Word Document? Thank you in advance!

Tommy19
 
If you want to display something like a Word document you can use the OLE control in the toolbox and point it to the Word document. You can right-click the control and insert the Word document in there. Then you can edit the document as if you were in Word.
 
Thank you for the help... sorry if I was unclear in my question.

but I have to go the other way. I start with no word doc. placing text according to x and y coordinates (using object.print) into a picbox and then transfering the image in that picbox into a Word Document or somehow saving it as a Word doc. Is this within the realm of possibilities? Thanks again in advance!
 
You'll need to add a reference to the Microsoft Word <x> Library to your project (where <x> represents version of Word you have installed). Then something like the following would work:
[tt]
Private Sub SavePicAsDoc(ctlPic As PictureBox, strDocument As String)
Dim myWord As Word.Application

Clipboard.Clear
Clipboard.SetData ctlPic, vbCFBitmap

Set myWord = New Word.Application
myWord.Documents.Add , , , True
myWord.Selection.Paste
myWord.ActiveDocument.SaveAs strDocument
myWord.Quit
Set myWord = Nothing

End Sub

Private Sub Command1_Click()
SavePicAsDoc Picture1, &quot;c:\test.doc&quot;
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top