ok, I'll try test it out! Thanks!
Main Topics
Browse All Topics2 issues with VBScript:
(1) The outputfile is csv but I'd prefer xls, if possible. Would like to format header with bold and when Category changes, add a row in the file to separate the Cateogories
(2) The script halts when it gets to the "Set file = fs.OpenTextFile......" with a 'Path not Found' with 4 Schoolnums. I checked the two data files and can't find the problem..as they both have the SCHOOLNUM. Until I find the error, can I run the script through by adding a line that runs past that error or will I have to do a SCHOOLNUM not in (....)?
Thank you.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Rob, thank you ---working so far, except for a couple of problems:
(1) First error: At objWB.Rows..., Object doesn't support this property or method:'objWB.Rows'
(2) Looks like the folders and files are created and then the error is Incorrect syntax near '=' at the Set resultSet2 = connect2.Execute(SQL1) line...maybe I missed something..what do you think I should be looking for?
(3) Not an error, but can I format the length of the columns with a line?
Hi, I don't actually think you need connect2 and ODBCDSN2. I'm pretty sure you can just get away with creating RecordSet and RecordSet2 from the same Connect object.
Try this. I have also fixed the Rows error, by creating a reference to the first sheet (you can change objWB.Sheets(1) in the code to reference another sheet if required). I have also added an "AutoFit" command to automatically expand the column width to fit.
Regards,
Rob.
Oh you what? Maybe that's a SQL error, and not a VBScript error.
SQL1 is this:
SQL1 = SQL1 & "from "
SQL1 = SQL1 & "FinalMasterExtract a, ErrorRecipients b "
SQL1 = SQL1 & "where a.SCHOOLNUM=b.SCHOOLNUM and b.SCHOOLNUM = "& o_Schoolnum &" "
try removing the spaces around the equals sign (and you don't need the blank bit at the end), so it becomes this:
SQL1 = SQL1 & "from "
SQL1 = SQL1 & "FinalMasterExtract a, ErrorRecipients b "
SQL1 = SQL1 & "where a.SCHOOLNUM=b.SCHOOLNUM and b.SCHOOLNUM=" & o_Schoolnum
Regards,
Rob.
Yes, the path is correct. The folder is created each time but the csv file, for some of the schoolnums, no longer gets created even though they did previously..one peculiar thing, it isn't creating any that are less than schoolnum=010. So any with 001,002,003 don't get created anymore.
Been trying one at a time (for example schoolnum='002' )and I know the data is in the file, but no success.
Hmmmm.. I just noticed that when you're checking for the folder, there's no backslashes between each value. Should there be?
Anyway, I haven't changed anything functionally, but I've made it a bit more readable. I've changed the folder path into one variable, so you only have to modify in one place. I've also added some message boxes as it deletes or creates so you can see the path it's referring to.
Let me know if the paths are correct, or if we need to add backslashes or something...
Regards,
Rob.
Rob:
I started narrowing down the variables using SCHOOLNUM and TYPE and was ok for most. When I would add back SchoolNameDistrict, it would create csv files for some and not others. So I went in the table and updated some of the SchoolNameDistrict names...maybe there were some transparent characters somewhere and it was playing havoc with the path? I don't know, but now I can use all variables and it works.
Now the script is working well, I will modify the code to the last version you offered. This is great, though. Thanks for working so long & patiently with me!
Business Accounts
Answer for Membership
by: RobSampsonPosted on 2008-09-23 at 23:51:17ID: 22557339
Hi, for requirement number 1, the easiest solution would probably be to programatically open each CSV after it's finished writing, then do a "Save As", and then do the formatting. The below code will do that.
For requirement number 2, the code below should address that too, at least by catching the error and telling you what it tried to open.
Regards,
Rob.
Select allOpen in new window