senatin Posted October 22, 2017 Share Posted October 22, 2017 (edited) I cant figure out how to make it work so far I got this code expandcollapse popup#include <WindowsConstants.au3> #include <GuiRichEdit.au3> #include <Excel.au3> HotKeySet( "{ESC}", "out") $Form1 = GUICreate("Senatin V.3.7.9", 466, 422, 79, 132) $hRichEdit = _GUICtrlRichEdit_Create($Form1, "", 12, 161, 241, 249, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL)) Local $xlup = -4162 Local $oExcel = _Excel_Open() If @error Then ConsoleWrite("Cant open Excel" & @CRLF) Exit EndIf Local $oWorkbook = _Excel_BookOpenEX($oExcel, @ScriptDir & "Book2.xlsx", True) If @error Then ConsoleWrite("Cant open book " & @error & @CRLF) _Excel_Close($oExcel) Exit EndIf Local $iRow = $oWorkbook.ActiveSheet.Range("A65536").End($xlup).Row InsertText( $iRow, 8, "-bo", 0x000000) GUISetState(@SW_SHOW) While 1 Sleep(100) WEnd Func _GUICtrlRichEdit_WriteLine($hWnd, $sText, $iIncrement = 0, $sAttrib = "", $iColor = -1) ; Count the @CRLFs StringReplace(_GUICtrlRichEdit_GetText($hWnd, True), @CRLF, "") Local $iLines = @extended ; Adjust the text char count to account for the @CRLFs Local $iEndPoint = _GUICtrlRichEdit_GetTextLength($hWnd, True, True) - $iLines ; Add new text _GUICtrlRichEdit_AppendText($hWnd, $sText & @CRLF) ; Select text between old and new end points _GuiCtrlRichEdit_SetSel($hWnd, $iEndPoint, -1) ; Convert colour from RGB to BGR $iColor = Hex($iColor, 6) $iColor = '0x' & StringMid($iColor, 5, 2) & StringMid($iColor, 3, 2) & StringMid($iColor, 1, 2) ; Set colour If $iColor <> -1 Then _GuiCtrlRichEdit_SetCharColor($hWnd, $iColor) ; Set size If $iIncrement <> 0 Then _GUICtrlRichEdit_ChangeFontSize($hWnd, $iIncrement) ; Set weight If $sAttrib <> "" Then _GUICtrlRichEdit_SetCharAttributes($hWnd, $sAttrib) ; Clear selection _GUICtrlRichEdit_Deselect($hWnd) EndFunc Func InsertText($text, $size, $bold, $clor) Static Local $Lasttxt = "" Static Local $Lastsize = 0 If $text <> $Lasttxt then $Lastsize = $size - $Lastsize _GUICtrlRichEdit_WriteLine($hRichEdit, $text , $Lastsize, $bold, $clor) $Lasttxt = $text $Lastsize = $size Endif EndFunc Func _Excel_BookOpenEX($oExcel, $sFilePath, $bReadOnly = Default, $bVisible = Default, $sPassword = Default, $sWritePassword = Default, $bUpdateLinks = Default) ; Error handler, automatic cleanup at end of function Local $oError = ObjEvent("AutoIt.Error", "__Excel_COMErrFunc") #forceref $oError If Not IsObj($oExcel) Or ObjName($oExcel, 1) <> "_Application" Then Return SetError(1, @error, 0) If Not FileExists($sFilePath) Then Return SetError(2, 0, 0) If $bReadOnly = Default Then $bReadOnly = False If $bVisible = Default Then $bVisible = True Local $oWorkbook = $oExcel.Workbooks.Open($sFilePath, $bUpdateLinks, $bReadOnly, Default, $sPassword, $sWritePassword) If @error Then Return SetError(3, @error, 0) Local $oWindow = $oExcel.Windows($oWorkbook.Name) ; <== Modified If IsObj($oWindow) Then $oWindow.Visible = $bVisible ; <== Modified ; If a read-write workbook was opened read-only then set @extended = 1 If $bReadOnly = False And $oWorkbook.Readonly = True Then Return SetError(0, 1, $oWorkbook) Return $oWorkbook EndFunc ;==>_Excel_BookOpen Func out() Exit EndFunc Can someone please help me. All I want to do is show info in _richedit enumerated base on their values Error is that _Excel_BookOpen or _Excel_BookOpenEX always return 2 Edited October 22, 2017 by senatin Link to comment Share on other sites More sharing options...
water Posted October 22, 2017 Share Posted October 22, 2017 Modify this line: Local $oWorkbook = _Excel_BookOpenEX($oExcel, @ScriptDir & "\Book2.xlsx", True) ; <== backslash added senatin 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...
senatin Posted October 22, 2017 Author Share Posted October 22, 2017 (edited) 1 hour ago, water said: Modify this line: Local $oWorkbook = _Excel_BookOpenEX($oExcel, @ScriptDir & "\Book2.xlsx", True) ; <== backslash added Yah Its working now Thank you Now next step. Hope I can figureout it straight till the end Edited October 22, 2017 by senatin Link to comment Share on other sites More sharing options...
water Posted October 22, 2017 Share Posted October 22, 2017 BTW: There is no need to quote my post - I know what I have written Just enter a reply at the end of the thread. 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