I have recently purchased Powershell Studio and love it. But now im trying script everything I can. I ran across a little repeatable process that outputs to an excel spreadsheet. So I am trying to edit a single cell in an existing spreadsheet. My googlefu must be bad, i cant find an example. Would anyone have a simple example of a script to open and edit a single cell and save then email the spreadsheet.
Thanks in advance
Dana
Powershell and Excel
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.
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.
Re: Powershell and Excel
Code: Select all
$xl = New-Object -Com Excel.Application
$doc = $xl.Workbooks.Open(<path to workbook>)
$xl.ActiveSheet.Cells.Item(2,3) = 'My value'
$doc.Save()
$doc.Close()
$xl.Quit()
Search for examples and you will find hundreds.
- danarstevenson
- Posts: 8
- Last visit: Wed Mar 20, 2024 5:41 am
- mxtrinidad
- Posts: 399
- Last visit: Tue May 16, 2023 6:52 am
Re: Powershell and Excel
Please feel free to check out my blog post at: http://www.maxtblog.com/2014/06/powersh ... into-excel
Look into the Excel section. You may find additional code that may interest you.
Look into the Excel section. You may find additional code that may interest you.