ashly Posted August 17, 2016 Posted August 17, 2016 I would like to create a new excel workbook and using below scripts. But it fails with @error=5 and @extended=-2147352567 I can't find out which part is wrong. Please help me~~~ #include <Excel.au3> Local $oResultExcel = _Excel_Open(False) Local $oResultBook = _Excel_BookNew($oResultExcel, 1) _Excel_BookSaveAs($oResultBook, "C:\test.xlsx", $xlWorkbookDefault) If @error Then Exit MsgBox(0, "Error!", "Error saving workbook to '" & $oResultBook & "'." & @CRLF & "@error = " & @error & ", @extended = " & @extended)
l3ill Posted August 17, 2016 Posted August 17, 2016 Try a different path, you may not have write access to C:\ My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example
ashly Posted August 17, 2016 Author Posted August 17, 2016 @l3ill Thanks for you reply. The path is just for this post. I'm actually using another path to save it in my USB stick.
l3ill Posted August 17, 2016 Posted August 17, 2016 Well I had the same error as you on a corp PC, when I changed the path it worked fine. My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example
water Posted August 17, 2016 Posted August 17, 2016 Which version of Office do you run? 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
water Posted August 17, 2016 Posted August 17, 2016 The decimal value of @extended translates to 0x80020009. This means: General Error. Only the error text would give more detailed error information. Which version of AutoIt do you run? 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
ashly Posted August 17, 2016 Author Posted August 17, 2016 I just changed the path to desktop then it works! Don't know why i cannot save it to my USB. Anyway, thank you so much, @l3ill
l3ill Posted August 17, 2016 Posted August 17, 2016 Cool, glad to help! Maybe if you get water the info he requested he can help with your usb conundrum... cya, Bill My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example
Shaik Posted October 9, 2018 Posted October 9, 2018 hi guys I am also facing the same error @error = , @extended = -2147352567 But here i am formatting the xls files to xlsx files . Through Automation i downloaded the xls file and opened, while saving the file to xlsx it showing the above error My AutoIt version - 3.3.14.2. All this time it is working fine , now it is throwing the error Says "Error While Saving Workbook to " I am attaching the AutoIt Script for your reference Thanks XlsToXlsx.au3
water Posted October 9, 2018 Posted October 9, 2018 Do you get a popup or error message when you save the workbook by hand ? 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
Shaik Posted October 10, 2018 Posted October 10, 2018 If try to save the file after formatting , it stuck some times and some times and sometimes it is working if changed the file name C:\Users\MasthanS\Perforce\InfactWorkspace\QAAutomation_FS\Infact\Automation_FactoryLogger\testData\08-10-2018\Run10\FactoryLogger_SmokeSuite\ShiftTest\ShiftSmokeTest\tc009\Intervaltc009_08_10_2018_22_17_18 This is my path where i am saving the files and also I am unable to close the excel files after formatting if some excel files are already open in taskbar. if it is only one then it is closing otherwise it is not closing how can i close the opened excel workbook file only thanks in advance
water Posted October 10, 2018 Posted October 10, 2018 Your path is 206 characters long. Including the filename this might exceed the Windows maximum length. Can you please test with a shorter path (maybe the desktop)? 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
Shaik Posted October 10, 2018 Posted October 10, 2018 Yeah, it is working fine now , thank you water thank you so much for the help than i need to change the path or reduce it After formatting the file , above _Excel_Close() func unable to close the file if already excel workbook files are open in taskbar, please help me in how i can close the only specified opened file
water Posted October 10, 2018 Posted October 10, 2018 Great this problem could be solved For the other problem you need to use _Excel_BookClose. 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
Shaik Posted October 10, 2018 Posted October 10, 2018 It throwing the error 'Error saving workbook.' @error=1 and @extended =0 At _Excel_BookClose Method it is showing the error #include <Excel.au3> #include <MsgBoxConstants.au3> ; Create application object Local $oExcel = _Excel_Open() If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookOpen Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended) ; Create a new workbook, write some data and close it without saving ; Create the new workbook Local $oWorkbook = _Excel_BookOpen($oExcel, "C:\Users\MasthanS.BSG\Downloads\Interval1" & ".xls") If @error Then MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookSaveAs Example", "Error opening workbook '" & $CmdLine[1] & ".xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended) _Excel_Close($oExcel) Exit EndIf ; ***************************************************************************** ; Save the workbook (xls) in another format (xlsx) to another directory and ; overwrite an existing version ; ***************************************************************************** Local $sWorkbook = "C:\Users\MasthanS.BSG\Downloads\Inter" & ".xlsx" _Excel_BookSaveAs($oWorkbook, $sWorkbook, $xlOpenXMLWorkbook, True) If @error Then Exit MsgBox ($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookSaveAs Example 1", "Error saving workbook to '" & $sWorkbook & "'." & @CRLF & "@error = " & @error & ", @extended = " & @extended) ;MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookSaveAs Example 1", "Workbook successfully saved as '" & $sWorkbook & "'.") ShellExecute($sWorkbook) ; Close the workbook without saving _Excel_BookClose($oWorkbook, False) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookClose Example 1", "Error saving workbook." & @CRLF & "@error = " & @error & ", @extended = " & @extended) MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookClose Example 1", "Workbook has been successfully closed.")
FrancescoDiMuro Posted October 10, 2018 Posted October 10, 2018 @Shaik Please use the Code tag. Your code unintelligible. Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
Shaik Posted October 10, 2018 Posted October 10, 2018 #include <Excel.au3> #include <MsgBoxConstants.au3> ; Create application object Global $oExcel = _Excel_Open() If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookOpen Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended) ; Create a new workbook, write some data and close it without saving ; Create the new workbook Local $oWorkbook = _Excel_BookOpen($oExcel, "C:\Users\MasthanS.BSG\Downloads\Interval1" & ".xls") If @error Then MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookSaveAs Example", "Error opening workbook '" & $CmdLine[1] & ".xls'." & @CRLF & "@error = " & @error & ", @extended = " & @extended) _Excel_Close($oExcel) Exit EndIf ; ***************************************************************************** ; Save the workbook (xls) in another format (xlsx) to another directory and ; overwrite an existing version ; ***************************************************************************** Global $sWorkbook = "C:\Users\MasthanS.BSG\Downloads\123" & ".xlsx" _Excel_BookSaveAs($oWorkbook, $sWorkbook, $xlOpenXMLWorkbook, True) If @error Then Exit MsgBox ($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookSaveAs Example 1", "Error saving workbook to '" & $sWorkbook & "'." & @CRLF & "@error = " & @error & ", @extended = " & @extended) ;MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookSaveAs Example 1", "Workbook successfully saved as '" & $sWorkbook & "'.") ShellExecute($sWorkbook) ; Close the workbook without saving _Excel_BookClose($oWorkbook, False) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookClose Example 1", "Error saving workbook." & @CRLF & "@error = " & @error & ", @extended = " & @extended) MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookClose Example 1", "Workbook has been successfully closed.")
water Posted October 10, 2018 Posted October 10, 2018 Did you have a look at the help file? All codes for @error are described there. 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
Shaik Posted October 10, 2018 Posted October 10, 2018 it is showing like this 1 - $oWorkbook is not an object or not a workbook object
water Posted October 10, 2018 Posted October 10, 2018 Is this the full script you run? Because I do not see a reason why $oWorkbook shouldn't be a valid object 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now