yasha Posted November 14, 2018 Share Posted November 14, 2018 $oExcel = ObjCreate("Excel.Application") ; Create an Excel Object $oExcel.Visible = 1 ; Let Excel show itself $oExcel = _Excel_Open() $oWorkbook = _Excel_BookOpen($oExcel, "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download\.xls files\INV_PLAN_PUR_ORDER " & $yy & $mm & $dd & ".xls") ;$sWorkbook = "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download\"& $YY & $MM & $DD & " INV_PLAN_PUR_ORDER.xlsx" $oExcel.ActiveWorkbook.SaveAs ( $sFileSelectFolder &"\INV_PLAN_PUR_ORDER " & $yy & $mm & $dd & ".xlsx",51,"","",False,False) $oExcel.ActiveWorkBook.Close i want to convert xls file to xlsx the problem here is that its super unstable and the person wants it in this format . ps i have no idea what the 51 after xlsx is i took this from the net and the excel save as udf keeps giving me this "C:\Users\etg.sgp.sysplan2\Documents\Program 2.au3" : ==> Variable used without being declared.: on this line _Excel_BookSaveAs($oWorkbook, $sWorkbook, $xlsx, True) even when i declare everything Link to comment Share on other sites More sharing options...
yasha Posted November 14, 2018 Author Share Posted November 14, 2018 @water@FrancescoDiMuro help please. Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted November 14, 2018 Share Posted November 14, 2018 @yasha The code you attached is not the one you are running. Post the code that you are running Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
water Posted November 14, 2018 Share Posted November 14, 2018 #include <Excel.au3> Global $oExcel = _Excel_Open() If @error Then Exit MsgBox(0, "Error", "_Excel_Open returned @error = " & @error & ", @extended = " & @extended) Global $sWorkbook = "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download\.xls files\INV_PLAN_PUR_ORDER " & $yy & $mm & $dd Global $oWorkbook = _Excel_BookOpen($oExcel, $sWorkbook & ".xls") If @error Then Exit MsgBox(0, "Error", "_Excel_BookOpen returned @error = " & @error & ", @extended = " & @extended) _Excel_BookSaveAs($oWorkbook, $sWorkbook & ".xlsx", $xlWorkbookDefault) If @error Then Exit MsgBox(0, "Error", "_Excel_BookSaveAs returned @error = " & @error & ", @extended = " & @extended) _Excel_BookClose($oWorkbook) If @error Then Exit MsgBox(0, "Error", "_Excel_BookClose returned @error = " & @error & ", @extended = " & @extended) _Excel_Close($oExcel) If @error Then Exit MsgBox(0, "Error", "_Excel_Close returned @error = " & @error & ", @extended = " & @extended) yasha 1 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 Link to comment Share on other sites More sharing options...
yasha Posted November 14, 2018 Author Share Posted November 14, 2018 @water do i need to change anything to overwrite an already existing excel file Link to comment Share on other sites More sharing options...
yasha Posted November 14, 2018 Author Share Posted November 14, 2018 @FrancescoDiMuro this is the correct code that i am running Spoiler Link to comment Share on other sites More sharing options...
yasha Posted November 14, 2018 Author Share Posted November 14, 2018 @FrancescoDiMuro ok more accurately what i need is to first select a folder to save my xlsx file in then i want to open an xlx file in another folder and then save it as xlsx file in the selected folder. thanks for answering my dumb questions #include <ClipBoard.au3> #include <ClipBoard.au3> #include <array.au3> #include <Date.au3> #include <Excel.au3> #include <ExcelConstants.au3> #include <MsgBoxConstants.au3> $variable1 = TimerInit AutoItSetOption ( "WinTitleMatchMode",2) AutoItSetOption ( 'MouseCoordMode',0) $sFileSelectFolder = FileSelectFolder("Select a folder", "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download") If @error Then ; Display the error message. MsgBox($MB_SYSTEMMODAL, "", "No folder was selected.") Exit Else ; Display the selected folder. MsgBox($MB_SYSTEMMODAL, "", "You chose the following folder:" & @CRLF & $sFileSelectFolder) EndIf EndIf ; $oExcel = ObjCreate("Excel.Application") ; Create an Excel Object $oExcel.Visible = 1 ; Let Excel show itself $oExcel = _Excel_Open() $oWorkbook = _Excel_BookOpen($oExcel, "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download\.xls files\SO " & $YY & $MM & $DD & ".xls", 1) ;$sWorkbook = "J:\OPS\OPS_Share\Planners\2 - Weekly Reports\Auto download\"& $YY & $MM & $DD & " INV_PLAN_PUR_ORDER.xlsx" $oExcel.ActiveWorkbook.SaveAs ( $sFileSelectFolder &"\SO " & $yy & $mm & $dd & ".xlsx",51,"","",False,False) $oExcel.ActiveWorkBook.Close Spoiler Link to comment Share on other sites More sharing options...
water Posted November 14, 2018 Share Posted November 14, 2018 Please have a look at the help file for _Excel_BookSaveAs to see how to overwrite an existing file yasha 1 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 Link to comment Share on other sites More sharing options...
water Posted November 14, 2018 Share Posted November 14, 2018 Yasha, do not mix _Excel* functions with directly using Excel COM (except where needed). Your code snippets show that this does not lead to the expected results 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 Link to comment Share on other sites More sharing options...
yasha Posted November 14, 2018 Author Share Posted November 14, 2018 (edited) 6 minutes ago, water said: @water is ther a way for my code to work ah wait forgot to ad in this $Nowtime = @YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC $YY=StringFormat("%02i",@YEAR-2000) $MM=StringFormat("%02i",Int(@MON)) $DD=StringFormat("%02i",Int(@MDAY)) Edited November 14, 2018 by yasha Link to comment Share on other sites More sharing options...
yasha Posted November 14, 2018 Author Share Posted November 14, 2018 @FrancescoDiMuro no soultion for me? Link to comment Share on other sites More sharing options...
yasha Posted November 14, 2018 Author Share Posted November 14, 2018 @water @FrancescoDiMuro solved it my god i am an idoit kept changing the wrong workbook setting thank you all so much for helping me out. Link to comment Share on other sites More sharing options...
water Posted November 14, 2018 Share Posted November 14, 2018 (edited) That's called "Learning by doing" Edited November 14, 2018 by water yasha and FrancescoDiMuro 2 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 Link to comment Share on other sites More sharing options...
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