Need help Saving .csv in script

Anything VBScript-related, including Windows Script Host, WMI, ADSI, and more.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Locked
User avatar
sayers
Posts: 5
Joined: Mon Jan 28, 2008 6:29 am

Need help Saving .csv in script

Post 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

User avatar
jdelatorre@hfinc.com
Posts: 54
Joined: Mon Sep 10, 2007 2:26 am

Need help Saving .csv in script

Post by jdelatorre@hfinc.com »

objExcel.ActiveWorkbook.SaveAs "d:appsbedtrackertest1.csv"

User avatar
sayers
Posts: 5
Joined: Mon Jan 28, 2008 6:29 am

Need help Saving .csv in script

Post by sayers »

Thanks Joel. That worked great. Does anyone know how I can save it without user intervention?

Thanks.

User avatar
sayers
Posts: 5
Joined: Mon Jan 28, 2008 6:29 am

Need help Saving .csv in script

Post by sayers »

I dont want it to ask for confirmation that I would like to save or overwrite the existing file.
Thanks

User avatar
jdelatorre@hfinc.com
Posts: 54
Joined: Mon Sep 10, 2007 2:26 am

Need help Saving .csv in script

Post 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.

jvierra
Posts: 14550
Joined: Tue May 22, 2007 9:57 am
Contact:

Need help Saving .csv in script

Post by jvierra »

It should be
objExcel.ActiveWorkbook.SaveAs "d:appsbedtrackertest1.csv", TRUE

jvierra
Posts: 14550
Joined: Tue May 22, 2007 9:57 am
Contact:

Need help Saving .csv in script

Post by jvierra »

Just happened to remember it as I don't use Excel much either. Databases are easier.

jvierra
Posts: 14550
Joined: Tue May 22, 2007 9:57 am
Contact:

Need help Saving .csv in script

Post by jvierra »

It takes a village - good luck.

Locked