View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Can you use a macro to insert a graphic? Or apply a template?

How are you importing the .csv data?

If you're using file|open, you could open the .csv file and then do all the
formatting, then create a new workbook based on your template, then copy the
..csv data into that workbook (first sheet???) and close the .csv file without
saving.

With no testing at all:

Dim CSVWks as worksheet
dim RptWks as worksheet

set csvwks = Workbooks.Open(Filename:="yourcsvfilename.csv").wo rksheets(1)

set rptwks _
= workbooks.add(Template:="C:\yourpath\myfile.xlt"). worksheets("sheet1")

'do the formatting work in csvwks if you want.
'or wait to do it in the template worksheet

csvwks.cells.copy _
destination:=rptwks.range("A1")

csvwks.parent.close savechanges:=false

============
If you're importing your csv data via Data|Import External Data, you should be
able to open the template file and import it directly onto the sheet you want.

TychaBrahe wrote:

We get a data export as a .csv that automatically opens Excel. I've
written/recorded a macro that sets column width, adds header rows and a
footer, changes fonts, and whatnot.

One thing I cannot make it do is insert a graphic of our logo. Any ideas?

In addition to having the graphic as a separate, importable file, I have it
in a template. The problem is that is seems the template only works for new
spreadsheets. It doesn't seem that you can apply it to an open worksheet the
way you can with a style in Word.

Is this graphic thing workable at all?


--

Dave Peterson