Jump to content

Recommended Posts

Posted

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.

  • Moderators
Posted

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?

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Posted

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.

 

Posted

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.

Posted

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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...