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

Need To Copy A JPG In A Gen Field To A Excel Cell

Status
Not open for further replies.

ReportMan

Programmer
Aug 13, 2001
40
0
0
US
I am trying to develop a excel spreadsheet that mirrors a set of reports. In a couple of the reports a JPG file stored in a General field in printed on the report. I need to know the method to allow me to copy the JPG file to a cell in the excel spreadsheet.
 
ReportMan

FAQ184-4212 would most likely help, although it shows you how to paste into Word document, the priciple wouls apply to an Excel document.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
I didn't find that of much help but have gotten the code to work up to a point. I can now create a JPG file from the FoxPro General field. The problem now is getting Excel to accept the JPG file.

Here is the code that I have written with sigfile the General Field in table UserInfo1. This is a 1 record table.

COPY TO tempsig FIELDS userinfo1.sigfile NEXT 1

*** execute the following code, assuming the file name for the output JPG image is "TestSig.JPG":
*** Open two files, "UserInfo1.fpt" contains the physical JPG data.
*** and Create a file handle for the output file "TestSig.JPG"
handlein = FOPEN("TempSig.fpt")
handleout = FCREATE("testsig.jpg")

*** To determine the length of the Input file "TempSig.fpt"
gnEnd = FSEEK(handlein, 0, 2)
gnTop = FSEEK(handlein, 0)

*** Store the whole file into a string "str1"
str1 = FREAD(handlein, gnEnd)

*** Offset 599 bytes from Str1 and save it to "str2"
str2 = RIGHT(str1,LEN(str1)-599)

*** Write "Str2" into the JPG file "TestSig.JPG"
n = FWRITE(handleout,str2)

*** Close both opened files
=FCLOSE(handlein)
=FCLOSE(handleout)

toSheet.Range("C28").Value = TempSig.JPG
 
ReportMan

I didn't find that of much help

I'm sorry it didn't help.

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