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.
This topic is 16 years and 1 month old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
sayers
Posts: 5
Last visit: Fri Feb 01, 2008 12:49 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
Last visit: Wed Jan 30, 2008 1:42 am

Need help Saving .csv in script

Post by jdelatorre@hfinc.com »

objExcel.ActiveWorkbook.SaveAs "d:appsbedtrackertest1.csv"
User avatar
sayers
Posts: 5
Last visit: Fri Feb 01, 2008 12:49 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
Last visit: Fri Feb 01, 2008 12:49 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
Last visit: Wed Jan 30, 2008 1:42 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: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Need help Saving .csv in script

Post by jvierra »

It should be
objExcel.ActiveWorkbook.SaveAs "d:appsbedtrackertest1.csv", TRUE
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

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: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Need help Saving .csv in script

Post by jvierra »

It takes a village - good luck.
This topic is 16 years and 1 month old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked