0

I want to create a Windows script to execute excel and open a file p and using the password

Example

Start excel c:\Documents\ExcelFile.xls 

but also I want to add the password

Start excel c:\Documents\ExcelFile.xls Password

But when I try to do that is not recognized

2 Answers 2

4

You can create a PowerShell script to perform that using Workbook Open function.

$path = "c:\temp\1.xls"
$password = "123"
$excel = New-Object -ComObject Excel.Application
$workbook = $excel.Workbooks.Open($path,$false,$false,5,$password)
$excel.Visible = $true

Save the script to a text file OpenExcel.ps1.

Usage:

powershell -file OpenExcel.ps1
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you im going to test :D
3

Excel has no command line switch to submit a password.
See Command-line switches for Microsoft Office products

But you can use a VBScript StartExcel.vbs instead of a batch file StartExcel.bat to do that:

Set oExcel = CreateObject("Excel.Application")
Set oWorkbook = oExcel.Workbooks.Open("c:\Documents\ExcelFile.xls", 0, 0, 5, "<myPassword")

1 Comment

Thank you I'm going to test :D

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.