$a = New-Object -ComObject excel.application
$a.visible = $TRUE
$a.DisplayAlerts = $FALSE
$b = $a.Workbooks.Open("d:\abc.csv")
$b.worksheets.add()
$c = $b.worksheets.Item(1)
$c.Cells.Item(1,1).Value() = "ABC"
$b.SaveAs("D:\abc.xlsx")
$a.Quit()
Try getting an instance of that specific sheet instead of "1":
PSH>$c = $b.worksheets.Item("sheet2")
PSH>$c.Cells.Item(1,1).Value() = "ABC"
Marco
--
Microsoft MVP - Windows PowerShell
http://www.microsoft.com/mvp
PowerGadgets MVP
http://www.powergadgets.com/mvp
"Marco Shaw [MVP]" <marco.shaw@_NO_SPAM_gmail.com> wrote in message
news:%23ryEOP1...@TK2MSFTNGP03.phx.gbl...
Can you provide some sample code (even if VBScript)? You mean you
actually want to paste a column into Excel while "pushing" the
existing column over?
Marco
Const xlShiftToRight = -4161
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
Set objWorkbook = objExcel.Workbooks.Add()
Set objWorksheet = objWorkbook.Worksheets(1)
objWorksheet.Cells(1,1) = "Dataset 1"
objWorksheet.Cells(1,2) = "Dataset 2"
objWorksheet.Cells(1,3) = "Dataset 4"
Set objRange = objExcel.Range("C1").EntireColumn
objRange.Insert(xlShiftToRight)
Michael
"Marco Shaw [MVP]" <marco.shaw@_NO_SPAM_gmail.com> wrote in message
news:uUpdBQ2Y...@TK2MSFTNGP06.phx.gbl...
Two line additional:
$e = $a.Range("A1").EntireColumn
$e.Insert()
The result is what I want. Thanks again!
Michael Gao
"Marco Shaw [MVP]" <marco.shaw@_NO_SPAM_gmail.com> wrote in message
news:uUpdBQ2Y...@TK2MSFTNGP06.phx.gbl...