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

How to send an image or picture into Excel Sheet using VFP

Status
Not open for further replies.

mariabenita

Programmer
Jun 18, 2001
13
0
0
SG
Good Day!
Is there any way to to send image or picture into Excel Sheet using VFP.

This is the sample of my codes.

tmpsheet = GetObject('','excel.sheet')
XLApp = tmpsheet.application
XLApp.Visible = .t.
XLApp.WorkBooks.Add()
XLSheet = XLApp.ActiveSheet

XLSheet.Cells(2,1).Value = "Item No "
XLSheet.Cells(3,1).Value = "Item name "
XLSheet.Cells(4,1).Value = "Picture "

XLSheet.Cells(2,2).Value = item.itemno
XLSheet.Cells(3,2).Value = item.itemname

**I'll try to use the following commands but the picture doesn't load.

**item.pix contains the filename of the picture
XLSheet.Cells(3,3).Picture = item.pix

** I also try to use this command
XLSheet.Oleobjects = item.pix
 
Was just going through the Excel programming help files. Now I've got Excel 2002 on this computer, so I'm not sure if it totally applies to older versions, but it appears you need to work with the 'shapes' collection. Here's a snippet of code found in the help for .addpicture method of the shapes collection

Code:
 Set myDocument = Worksheets(1)
myDocument.Shapes.AddPicture _
    "c:\microsoft office\clipart\music.bmp", _
    True, True, 100, 100, 70, 70

Bear in mind that it's written in code for VB, but it shouldn't be hard to modify for VFP. You should read the details in the help file to see what all the parameters mean. Hope this helps.

Dave Dardinger



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top