![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Re: Import .csv file You need to make the other sheet active before you save: $xl= new-object -com Excel.Application $xl.visible = $true $xl.displayalerts=$false $wb = $xl.workbooks.open("C:\Book1.xls") $sheet1 = $wb.worksheets | where {$_.name -eq "s1"} $wb.saveAs("c:\sheet1.csv", 6) $sheet2 = $wb.worksheets | where {$_.name -eq "s2"} $sheet2.select() $wb.saveAs("c:\sheet2.csv", 6) $xl.quit() To save all worksheets to csv files: $wb.worksheets | foreach { $_.select() $wb.saveAs("c:\"+$_.name+".csv", 6) } --- Shay Levy Windows PowerShell http://blogs.microsoft.co.il/blogs/ScriptFanatic Quote: > Right. I get that, but what I'm trying to do is to have one existing > file, and then end up with two different files because I have two > different csv files. But I don't know how to get the second sheet to > SaveAs so I can import it in PowerShell. I can get the first sheet to > SaveAs but the second sheet seems to ignore the code. I've been using > this code but it seems to not work. Should I be using a different > code? > > $optionSheet.SaveAs("C:\Users\options.csv", 6) > > ronni > |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Import .csv file I used the code, but it still won't activate the second sheet. Everything else works just like it should but the second sheet won't saveas and won't import in PowerShell. Is there something that I'm not doing correctly? ronni |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Import .csv file I used excel 2007 to test the code, what's youre version? What happens if you try the second part where you can save all sheets? --- Shay Levy Windows PowerShell MVP http://blogs.microsoft.co.il/blogs/ScriptFanatic Quote: > I used the code, but it still won't activate the second sheet. > Everything else works just like it should but the second sheet won't > saveas and won't import in PowerShell. Is there something that I'm not > doing correctly? > > ronni > |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Import .csv file I'm usng excel 2007 as well. When I use the second part of the code, I get an error saying that I cannot access read-only documents. I didn't see this before because I put it in a function that I'm creating. How do I make it so that the documents aren't in read-only? ronni |
My System Specs![]() |
| | #5 (permalink) |
| | Re: Import .csv file Can you create a sample excel file with two or three sheets, save it locally on your hard drive and try the code again. BTW, doe's your regional settings set to en-US? --- Shay Levy Windows PowerShell http://blogs.microsoft.co.il/blogs/ScriptFanatic Quote: > I'm usng excel 2007 as well. > > When I use the second part of the code, I get an error saying that I > cannot access read-only documents. I didn't see this before because I > put it in a function that I'm creating. How do I make it so that the > documents aren't in read-only? > > ronni > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| How to import pst file into Windows mail | Vista mail | |||
| Import from OE6 via CSV File...Is it possible??? | Vista mail | |||
| My new Vista PC IE will not import my bookmark.htm file from XP PC | Vista General | |||
| can't import ics file | Vista mail | |||
| Can't Import .pst file into Windows Mail | Vista mail | |||