Page 1 of 1

Need help Saving .csv in script

Posted: Mon Jan 28, 2008 5:34 am
by sayers
Need help getting this file to save. I am wanting to use this script to open a text file and save it as a .csv and then close. The file is in a fixed field format. Thanks for any help you can provide. Should be easy, but this is my first script. Thanks.

Const xlFixedWidth = 2
Set objExcel = CreateObject("Excel.Application")objExcel.Visible = TrueobjExcel.Workbooks.OpenText _ "C:Documents and Settingsspa2329DesktopNew FolderTest1",,,xlFixedWidth,,,,,,,,,Array(Array(0,1),Array(12,1),Array(22,1))objExcel.Workbooks.Open.SaveA("d:appsbedtrackertest1.csv")objExcel.Quit

Need help Saving .csv in script

Posted: Mon Jan 28, 2008 5:54 am
by jdelatorre@hfinc.com
objExcel.ActiveWorkbook.SaveAs "d:appsbedtrackertest1.csv"

Need help Saving .csv in script

Posted: Mon Jan 28, 2008 6:50 am
by sayers
Thanks Joel. That worked great. Does anyone know how I can save it without user intervention?

Thanks.

Need help Saving .csv in script

Posted: Mon Jan 28, 2008 7:05 am
by sayers
I dont want it to ask for confirmation that I would like to save or overwrite the existing file.
Thanks

Need help Saving .csv in script

Posted: Mon Jan 28, 2008 7:18 am
by jdelatorre@hfinc.com
The saveas method has a grip of parameters for it. I think it does have one that you can pass to overwrite, etc.. Lookup the method on MSDN.

Need help Saving .csv in script

Posted: Mon Jan 28, 2008 7:29 am
by jvierra
It should be
objExcel.ActiveWorkbook.SaveAs "d:appsbedtrackertest1.csv", TRUE

Need help Saving .csv in script

Posted: Mon Jan 28, 2008 10:56 am
by jvierra
Just happened to remember it as I don't use Excel much either. Databases are easier.

Need help Saving .csv in script

Posted: Tue Jan 29, 2008 1:55 am
by jvierra
It takes a village - good luck.