Solved

Foxpro - How do I programmatically add a pic to an Excel SS

Posted on 2010-09-07
3
428 Views
Last Modified: 2012-05-10
I've been writing reports to Excel via Foxpro for years but unitl now I've never had to include an image.  This particual report concerns lab results where reference range explanations are quite long for two particular tests.  Since I need to provide all the results for an exam on one 8.5X11 sheet it's important that I not use one row per reference range line explanation and that's why I'm opting to include an image (see attached) instead.  I've also include a sample of the lab result report.  The list of test result is always different and may or may not include the two test results with the reference ranges that I've highlighted.  Please include your recommendations or a code sample.  Thanks in advance for your help.  For refrence, the change I'm incorporating is to an old VFP 6 application.
labsliptemplate.htm
HbA1c.jpg
0
Comment
Question by:NIDDK1550
3 Comments
 
LVL 12

Expert Comment

by:jrbbldr
ID: 33621181
The place to start with anything like this is to do the same work manually in Excel and record the operations in an Excel Macro.

Then go into the Macro and examine the steps that it recorded.  Yes it will be in VBA code rather than VFP, but typically it is not too difficult to see what is going on and convert it to VFP Automation code.

Good Luck

0
 
LVL 29

Expert Comment

by:Olaf Doschke
ID: 33621493
No need to put this into an image, you can do multiline text into a cell by typing ALT+RETURN. In code you simply set a cell value to multiline text with CHR(10) as line feeds. I don't see why you would need pictures to do this.

Otherwise there is no such thing as a picture in a cell, pictures are put on a sheet as far as I found out. You can do ActiveSheet.Pictures.Insert ("C:\...\some.jpg") and the picture will be on the sheet, it can be positioned anywhere and is not bound to cells.

Bye, Olaf.
0
 
LVL 27

Accepted Solution

by:
CaptainCyril earned 500 total points
ID: 33622520
cMyPicture = SYS(5)+SYS(2003)+'logo.bmp' && a sample file

xlsheet.Columns(1).ColumnWidth = 4.25
xlsheet.Range("A1").Select
xlshape = xlsheet.Pictures.Insert(platformfile(cMyPicture)
WITH xlshape
*      .LockAspectRatio = msoTrue
      .Height = .Height*3/4 && three quarters of the logo's height
      .Width = .Width*3/4 && three quarters of the logo's width
ENDWITH
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now