Mhj96813 Posted February 21, 2019 Share Posted February 21, 2019 I have a script that finds and open application and then collects some info. It then opens excel and does a bunch of _Excel_RangeWrite's to a blank worksheet. Then it sends some keys to the active application and then does some more _Excel_RangeWrite's. It does this until conditions are met on the application. When I'm all done I would like to do some formatting in the excel spreadsheet. I'm sure its easy but I can't figure out how to make the Excel worksheet active so I can send key strokes to it. I start off: Global $oExcel = _Excel_Open() Global $oWorkbook = _Excel_BookNew($oExcel) Local $aArray1D[1][30] = [["item","Operation","Resource Group","Resource","description","demand QTY","Delay (days)","Order Minimum","Order Maximum","Order Multiple","Fixed Lead Time (days)","Var. Lead Time (hrs.)"," Expedited Fixed Lead Time (days)","Expedited Var. Lead Time (hrs.)","Start Date End Date","Work Center","Duration","Number of Members","Delay (days)","Request Date","Usage Date","Supply ID","Inventory Date","On hand Qty","Usage Qty","Shift ID#1","Shift ID#2","Shift ID#3","Shift ID#4"]] _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $aArray1D, "A1") Then I WinActivate("Infor ERP SL (cda) - Demand Detail Chart APS ", "") I grab some values from the app and send write them to excel _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $val1, "A"& $intRow) Do I make the excel object active? or the workbook object active? and if so how? Link to comment Share on other sites More sharing options...
Skeletor Posted February 22, 2019 Share Posted February 22, 2019 (edited) Basically, after you insert data into your sheet, you then format it. Like this: #include <EXCEL.AU3> Global $oExcel = _Excel_Open() Global $oWorkbook = _Excel_BookNew($oExcel) Local $aArray1D[1][30] = [["item", "Operation", "Resource Group", "Resource", "description", "demand QTY", "Delay (days)", "Order Minimum", "Order Maximum", "Order Multiple", "Fixed Lead Time (days)", "Var. Lead Time (hrs.)", " Expedited Fixed Lead Time (days)", "Expedited Var. Lead Time (hrs.)", "Start Date End Date", "Work Center", "Duration", "Number of Members", "Delay (days)", "Request Date", "Usage Date", "Supply ID", "Inventory Date", "On hand Qty", "Usage Qty", "Shift ID#1", "Shift ID#2", "Shift ID#3", "Shift ID#4"]] _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $aArray1D, "A1") ; Use the For Loop to write to all your rows and columns. For $i = 1 To 30 Step 1 _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $val1, "A" & $intRow) Next ;WinActivate("Infor ERP SL (cda) - Demand Detail Chart APS ", "") $oWorkbook.Sheets(1).Name = "Infor ERP SL (cda) - Demand Detail Chart APS " ;Rename your worksheet ; Note if you have more than one worksheet on an Excel work book, then name it according. ;================================================= ;Example: Sheets(1), Sheets(2), Sheets(3), etc... ;================================================= ; $oWorkbook.Sheets(1).Name = "" ; $oWorkbook.Sheets(2).Name = "" ; $oWorkbook.Sheets(3).Name = "" $oWorkbook.ActiveSheet.Columns("A:AC").AutoFit ;Auto fits all the colomns... can remove this if its not required. With $oExcel.ActiveWorkbook.Sheets(1) .Range("A1:AC1").Font.Bold = True ;Makes the font bold .Range("A1:AC1").Interior.Color = 0xABCDEF ; Adds color .Range("A1:AC1").Borders.LineStyle = 1 ;Adds a border to the row and column EndWith ; Then Save the file _Excel_BookSaveAs($oWorkbook, @TempDir, $xlExcel8, True) ;Excel 97-2003 Workbook By the way, all thanks to @water for this Excel UDF. This UDF saves me a ton of time everyday at work. Edited February 22, 2019 by Skeletor Kind RegardsSkeletor "Coffee: my defense against going postal." Microsoft Office Splash Screen | Basic Notepad Program (Beginner) | Transparent Splash Screen | Full Screen UI Link to comment Share on other sites More sharing options...
water Posted February 22, 2019 Share Posted February 22, 2019 2 hours ago, Skeletor said: By the way, all thanks to @water for this Excel UDF. This UDF saves me a ton of time everyday at work. Glad you like the UDF 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...
LandonEvans Posted March 2, 2019 Share Posted March 2, 2019 I use ZetExcel and it does everything I need with regards to parsing MS Excel files. https://zetexcel.com/ Link to comment Share on other sites More sharing options...
Skeletor Posted March 2, 2019 Share Posted March 2, 2019 1 hour ago, LandonEvans said: I use ZetExcel and it does everything I need with regards to parsing MS Excel files. https://zetexcel.com/ Cool, but I wont be rushing anytime soon to place a $99 Dev license... How bout showing some examples of what you mean? Kind RegardsSkeletor "Coffee: my defense against going postal." Microsoft Office Splash Screen | Basic Notepad Program (Beginner) | Transparent Splash Screen | Full Screen UI Link to comment Share on other sites More sharing options...
water Posted March 2, 2019 Share Posted March 2, 2019 The post count of LandonEvans is 2 and both posts were to advertise this/his tool. Seems he just came here to sell the product Skeletor 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...
Nine Posted March 3, 2019 Share Posted March 3, 2019 2 hours ago, water said: The post count of LandonEvans is 2 and both posts were to advertise this/his tool. Seems he just came here to sell the product “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy 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