Jump to content
Wolfiesaxah

$oExcel.ActiveWorkbook.Save() started Failing

Recommended Posts

Wolfiesaxah

I have a script that opens an excel file then checks each rows, deleting bad ones etch. After the process the script does a "$oExcel.ActiveWorkbook.Save()" to save the changes made (the file is .xlsx). This part of the script has always worked in the past but recently started giving me an error 

 ==> The requested action with this object has failed.:
$oExcel.ActiveWorkbook.Save()
$oExcel.ActiveWorkbook.Save()^ ERROR

Then after getting this error I try to check the Excel file but it is not clickable, the save button is not clickable either, only the X or Close Window button is. Could I be getting this error because Excel somehow froze? Can anyone tell me why it was freezing at that point? It has worked well in the past.

Share this post


Link to post
Share on other sites
JLogan3o13

Wolfiesaxah, do you honestly think we will be able to troubleshoot your issue based on a single line of code? How about posting the entire code, or at least a runnable reproducer.

And while we're at it, is there a reason (have to ask, since your code isn't posted), you're not working with the built in Excel functions to save and close the workbook?


√-1 2^3 ∑ π, and it was delicious!

How to get your question answered on this forum!

Share this post


Link to post
Share on other sites
dmob

I think I might have had a similar problem in the past, check if it's not related to this...

from the help file for _ExcelBookSaveAs:

Starting with Excel 2007 you have to provide both the $iFormat parameter and the correct file extension in $sFilePath.
E.g. $iFormat = $xlExcel8 and extension = "xlsx" will return an error.
 

 

Just a long shot, but I suspect your problem might be related to dissimilar formats when opening and saving your workbook.

 

Share this post


Link to post
Share on other sites
Wolfiesaxah

Thanks guys, I'm not sure what the problem is but I tried debugging and all I can see is that the Excel save button is disabled so that could be why the script is failing at saving so I modified my script to just open the excel file to get the required data then closing Excel without saving. I am using notepad and string concatenation as planB since using Excel seem to be more complicated.

Share this post


Link to post
Share on other sites
water

Please post your script so we can have a look at it.
Automating Excel using the builtin UDF is not complicted at all.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×