$a = New-Object -ComObject Excel.Application
$a.Visible = $True
$a.DisplayAlerts = $False
$a.workbooks.open("d:\out\book1.xlsx")|out-null
Thanks.
MG
Are you willing to use something 3rd party like AutoIt
(http://www.autoitscript.com/)?
You need a way to automate the writing of text to a particular window...
Marco
$missing = [System.Reflection.Missing]::Value
$a.Workbooks.Open( "d:\out\book1.xlsx",
$missing, $missing, $missing,
"readPassword", "writePassword" )
--
Joel
This will open a protected password file with a read/write password of "shay",
tested on Excel 2007:
$xl = New-Object -com Excel.Application
$xl.visible=$true
$xl.Workbooks.open("D:\pass.xls",1,$false,5,"shay","shay")
You can get help on the Workbooks.Open Method, paste the following to the
run dialog and press enter:
ms-help://MS.EXCEL.DEV.12.1033/EXCEL.DEV/content/HV10063099.htm
---
Shay Levy
Windows PowerShell MVP
http://blogs.microsoft.co.il/blogs/ScriptFanatic
PowerShell Toolbar: http://tinyurl.com/PSToolbar
MG> Hi,
MG> I have an Excel file with password protected and I know the
MG> password. How
MG> can I change the script to open it without prompt my password?
MG> $a = New-Object -ComObject Excel.Application
MG> $a.Visible = $True
MG> $a.DisplayAlerts = $False
MG> $a.workbooks.open("d:\out\book1.xlsx")|out-null
MG> Thanks.
MG> MG
I never checked the open method, and whether it supported extra values.
The others have pointed out a much better method.
Marco
Josh
"Michael Gao" <gaoy...@hotmail.com> wrote in message
news:ekIDjlIm...@TK2MSFTNGP03.phx.gbl...
Thanks!
MG
"Shay Levy [MVP]" <n...@addre.ss> wrote in message
news:95d808936e85c8...@news.microsoft.com...