Can you use a macro to insert a graphic? Or apply a template?
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? |
Can you use a macro to insert a graphic? Or apply a template?
You should be able to use something like the following:
ActiveSheet.Pictures.Insert( _ "C:\Documents and Settings\Documents\My Pictures\Sample Pictures\Sunset.jpg" _ ).Select Just change the file location to match your logo. You can then record a macro of you adjusting size, if necessary. -- Best Regards, Luke M *Remember to click "yes" if this post helped you!* "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? |
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 |
All times are GMT +1. The time now is 04:28 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com