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

Pasting a Picture to clip board - URGENT.

Status
Not open for further replies.

FoxLearner

Programmer
Aug 29, 2002
93
US
Hi
I am working on mail merge. I am opening a word template and merging text from a cursor(fields) into the word template to make a letter. However, I have a prbolem with a General field in the cursor where a logo is stored. I can't insert that in to the word document.
Is there a way I can insert it in to the word file? As an alternative if I can paste it to clip board, it would solve my problem. I know how to insert from a clip board.

Thanks and regards
FoxLearner
 
Foxlearner - did you find a solution to this?

Regards

Griff
Keep [Smile]ing
 
There IS an MS article on doing this - but I havn't got it to work yet either!

If I manage it - I'll let you know

Regards

Griff
Keep [Smile]ing
 
Foxlearner,

This is the best I can come up with:

Code:
m.tempdir = "c:\temp\"
m.filename = "c:\mydata\word\mydocument.doc"
** m.logo is used to prevent trying to paste something that isn't there
m.logo = .f.
** poppj has my general field (logo - but it doesn't matter, it won't work if there are more that one general/memo field)
select poppj
** I only have one live record (might be a deleted on though)
go top
copy to (m.tempdir+"tmppj") next 1
** test for success
if myfile(m.tempdir+"tmppj.fpt")
        ** read the WHOLE memo field into a string
	m.string = filetostr(m.tempdir+"tmppj.fpt")
        ** write it all out (minus the first 599 bytes)
	strtofile(right(m.string,len(m.string)-599),m.tempdir+"tmplogo.bmp")
        ** set the success flag
	m.logo = .t.
endif
** open up word
oWordObj = CREATEOBJECT("Word.Application")
** seems to work better when visible
oWordObj.Visible = .T.
** add a document
loDocument = oWordObj.Documents.Add()
** create a selection
loSelection = oWordObj.Selection
loSelection.Font.Name = "Arial"
** add a table
loSelection.Tables.Add(loSelection.Range, 1, 2)
** if you have a logo use it
if m.logo
        ** insert the picture
	loSelection.InLineShapes.AddPicture(m.tempdir+"tmplogo.bmp")
endif
** done!
loDocument.SaveAs(M.FILENAME)
oWordObj.Quit()
RELEASE oWordObj

Only works with .bmp files.

HTH

Regards

Griff
Keep [Smile]ing
 
FoxLearner

If its copying TO the clipboard, take a look at:
thread184-691344

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top