View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Jon Peltier Jon Peltier is offline
external usenet poster
 
Posts: 6,582
Default Create a chart from a "txt" or a "csv" file

Hi Mark -

It's probably not too complicated, unless your data is much more intricate
than you've let on. Record a macro while you open the text file as a new
workbook, create a chart from this data, then export the chart to GIF or PNG
format (don't use JPG). Or you could copy the chart as a picture and paste
it into the sheet. After the chart is created, you can delete the data.

If you wanted to get more intricate, you could read the file in VBA, and use
the data as arrays to populate the chart, as long as there aren't too many
points. But Excel charts work more reliably when the data comes from a
worksheet.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"Mark Ivey" wrote in message
...
Thanks for the reply Peter...

In a nutshell, here is what I am trying to accomplish.

I would like to build the chart from this external data (which was
generated previously in my code) and then cut and paste the chart as a jpg
or something like that (so it will not be dependent on the outside source
after creation.

Do you have any code samples on how to build a chart from a CSV file?

TIA...
Mark


"Peter T" <peter_t@discussions wrote in message
...
Chart data can exist in another (closed) workbook, even a CVS, but not in
a
text file.
If there are no other factors apart from merely keeping the chart & data
separate, it would be easier to keep data in an ordinary xls.

Manually or programmatically, the csv/xls would need to be open while
actually making the chart and linking source data. Thereafter it can
remain
closed, though you will probably get messages about links.

You could link cells in the data file to cells in the chart file.
Programmatically that could in theory be done without opening the data
file
with =['c:\path\fileName.csv]SheetName'!A1 as cell formulas; but why
bother,
simpler to open the data csv to establish the links then close.

If the original data is in a text file probably easiest to copy the data
to
cells, as source for the chart. Thereafter there are various ways of
removing the data from the cells though data would in effect exist
thereafter in the chart file.

Just a few thoughts

Regards,
Peter T


"Mark Ivey" wrote in message
...
Is is possible to create a chart from an external data source like a
text
file or a csv file with VBA and keep the data external?

If anyone has any experience with this topic, I would really appreciate

some
examples.


The data I am working with is formatted as such:

METER, CHANNEL
12, 8
47, 10
349, 8


TIA...
Mark Ivey