Bagel Posted April 2, 2021 Share Posted April 2, 2021 Maybe I'm going nuts here or just missing something obvious but I can' figure out which it is. Why doesn't the below code properly save the Excel workbook? I've tried the script directory, the desktop, format variations, nothing works. #include <Excel.au3> $ExcelFileName = @ScriptDir & '\Book1.xlsx' $oExcel = _Excel_Open(Default, Default, True, Default, True) $ExcelBook = _Excel_BookOpen($oExcel, $ExcelFileName) _Excel_BookSaveAs($ExcelBook, @ScriptDir & "\Book-2.xlsx", "xlsx") Link to comment Share on other sites More sharing options...
TheXman Posted April 2, 2021 Share Posted April 2, 2021 (edited) If you read the help file's definition of _Excel_BookSaveAs(), you will see that the 3rd parameter can be any value of the XlFileFormat enumeration, none of which is "xlsx". Search for "XlFileFormat Enumeration" in the ExcelConstants.au3 file for a list of the values. It also talks about it in the Remarks section. If you want to save a .xlsx, then one the following enums should work: $xlOpenXMLWorkbook = 51 ; Open XML Workbook (without macro’s in 2007, .xlsx) $xlOpenXMLWorkbookMacroEnabled = 52 ; Open XML Workbook Macro Enabled (with or without macro’s in 2007, .xlsm) $xlWorkbookDefault = 51 ; Workbook default (.xls for < Excel 2007, .xlsx for > Excel 2007) Edited April 2, 2021 by TheXman CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
Bagel Posted April 2, 2021 Author Share Posted April 2, 2021 Well, I thought that might be it at one point which is when I tried #include <Excel.au3> $ExcelFileName = @ScriptDir & '\Book1.xlsx' $oExcel = _Excel_Open(Default, Default, True, Default, True) $ExcelBook = _Excel_BookOpen($oExcel, $ExcelFileName) _Excel_BookSaveAs($ExcelBook, @ScriptDir & "\Book-2.xlsx", "$xlWorkbookDefault") which also doesn't work for me. So I'm still at square 1. Link to comment Share on other sites More sharing options...
TheXman Posted April 2, 2021 Share Posted April 2, 2021 (edited) You do not need the double quotes around the enum. Look at the example in the help file! If you are going to use the default, then you don't even need to supply the 3rd parameter. Edited April 2, 2021 by TheXman CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
Bagel Posted April 2, 2021 Author Share Posted April 2, 2021 WOW. I would have sworn that I had already tried that and received an invalid function error. The only thing I can think of is that in my earlier attempt I had omitted the '$' when copy-pasting. Of course, after seeing the error I abandoned that approach. Thanks, and sorry for wasting your time with such a minor issue. Link to comment Share on other sites More sharing options...
TheXman Posted April 3, 2021 Share Posted April 3, 2021 (edited) You're welcome. 😀 Edited April 3, 2021 by TheXman CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
Bagel Posted April 3, 2021 Author Share Posted April 3, 2021 For the sake of posterity I just realized how the error happened. When researching the file types I was referencing a page on GitHub. I'm so used to selecting variables in SciTE by double clicking on them to select the entire variable name that that's what I did in trying to copy the variable name from the web page. And when I do that from the web page it automatically selects all of the text EXCEPT the '$'. What bizarre error. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 29, 2022 Moderators Share Posted November 29, 2022 Kerrymahoni, The post above yours explains how the problem arose - and that there really was no "solution" to find. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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