cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
3134
Views
0
Helpful
1
Replies

Error while creating Excel file using powershell script

vigneswaram
Level 1
Level 1

Hi Team,

I am facing an error while creating Excel file using powershell script.

My requirement is to create excel sheet with two workbooks and add some columns and rows to each workbook.

When I run the same code using "Windows powershell ISE", it is working without any issues. But not from CPO activity.

 

When I use:

$excel = New-Object -comobject Excel.Application

$workbook = $excel.Workbooks.Add()

 

Results in error:

Exception calling "Add" with "0" argument(s): "Microsoft Office Excel cannot open or save any more documents because there is not enough available memory or disk space. • To make more memory available, close workbooks or programs you no longer need. • To free disk space, delete files you no longer need from the disk you are saving to."At C:\Reporting\Temp\PO_WorkingDir_7bdb6c15-43c4-49b6-8049-d22243a77844\PO_PSScript_7bdb6c15-43c4-49b6-8049-d22243a77844.ps1:35 char:1+ $RequisitionWorkbook = $ExcelObject.Workbooks.Add()+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException    + FullyQualifiedErrorId : ComMethodTargetInvocation 

Please find the attached screen shot for image reference. Could anyone provide the support  to resolve this?

Note: We are sure the server is dfinitely not lacking for resources..

 

Regards,

Vignesh

1 Reply 1

Shaun Roberts
Cisco Employee
Cisco Employee

Can you check the solutions here and see if anything helps you?

 

http://stackoverflow.com/questions/687891/exception-automating-excel-2007-with-powershell-when-calling-workbooks-add

Seems people getting this error when they do not set the culture for the file specifically.

 

If that does not help, can you see what happens when you just do the first statement via CPO and just create an excel file. Does it set the file as blocked? I see that a lot here, so see if this article helps:

 

http://stackoverflow.com/questions/12415690/how-to-fix-microsoft-excel-cannot-open-or-save-any-more-documents

 

 

I have not tried this particular use case before.

--Shaun Roberts
Principal Engineer, CX
shaurobe@cisco.com

Review Cisco Networking for a $25 gift card