Running an excel macro from Powershell


hello all!

i trying run excel macro that's stored in personal.xls file (in xlstart folder), in automated script.  the problem is, can run macro when put commands in manually, when script is running, get: exception calling "run" "31" argument(s): "'personal.xls' not found.

here's code macro section:

	$excel = new-object -comobject excel.application  	$workbook = $excel.workbooks.open("c:\test.xls")  	$worksheet = $workbook.worksheets.item(1)  	$excel.run("personal.xls!fmt_pricecheckstore")  	$workbook.close()  	$excel.quit()
in advance assistance!

hi,

i don’t know if it’s possible run macro in not-opened excel file.

could open personal.xls file $workbook = $excel.workbooks.open("personal.xls") , run macro?

or add variable $workbook2 = $excel.workbooks.open("personal.xls").

thanks.


this posting provided "as is" no warranties, , confers no rights.


Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Group Policy Event ID 1058 Error Code 1326 (The user name or password is incorrect)

Suspicious event log Event ID: 4905

DCOM received error "2147746132" from...