Jump to content

xls to xlsx conversion program help


yasha
 Share

Recommended Posts

$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

#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)

 

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

@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

Please have a look at the help file for _Excel_BookSaveAs to see how to overwrite an existing file ;)

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

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

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 by yasha
Link to comment
Share on other sites

That's called "Learning by doing" ;)

Edited by water

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

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
 Share

  • Recently Browsing   0 members

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