Jump to content

HarishIyer

Members
  • Posts

    7
  • Joined

  • Last visited

HarishIyer's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. HI Water, I found objget to work but objcreate doesnt work! In the example you can see for word.application objget works but fails for excel Many Thanks, Harish Iyer
  2. Hi Water, Thanks for the reply. The error description is OK We intercepted a COM Error ! err.description is: err.windescription: Unspecified error err.number is: 80004005 err.lastdllerror is: 0 err.scriptline is: 15 err.source is: err.helpfile is: err.helpcontext is:
  3. HI Guys, I got the below code from autoit . It basically embeds a blank word in a gui. #include <GUIConstants.au3> #include <WindowsConstants.au3> Global $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") Main() Func Main() Local $oWordApp = ObjCreate("Word.Application") Local $oWord = ObjCreate("Word.Document") $oWord.Activate Local $oWordEvent = ObjEvent($oWord, "WordEvent") Local $hWnd = GUICreate("Test", 800, 600, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPCHILDREN)) GUICtrlCreateObj($oWord, 10, 155, 300, 300) GUICtrlCreateTab(0, 0, 800, 600, $WS_CLIPSIBLINGS) GUICtrlCreateTabItem("Test1") GUICtrlCreateTabItem("Test2") GUICtrlCreateTabItem("") For $oCommandBar In $oWord.CommandBars If $oCommandBar.Type < 2 Then $oCommandBar.Enabled = False EndIf Next $oWord.CommandBars("Reviewing").Visible = False $oWord.CommandBars("Standard").Visible = False $oWord.CommandBars("Formatting").Visible = False $oWord.Activewindow.DisplayRulers = False $oWord.Activewindow.Split = False $oWord.Activewindow.SplitVertical = 0 $oWord.Application.DisplayScrollBars = False $oWord.Activewindow.View.Type = 6 $oWord.Activewindow.View.DisplayPageBoundaries GUISetState(@SW_SHOW, $hWnd) While WinExists($hWnd) Local $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then GUIDelete() WEnd EndFunc ; Main() Func WordEvent($sEvent) TrayTip("", "Event: " & $sEvent, 5) EndFunc Func MyErrFunc() Local $HexNumber=hex($oMyError.number,8) Msgbox(0,"AutoItCOM Test","We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & $HexNumber & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext ) SetError(1); to check for after this function returns Endfunc I tried to change it for Excel as below. #include <GUIConstants.au3> #include <WindowsConstants.au3> $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") Main() Func Main() $VersionNumber = '3.01' Local $oExcel = ObjCreate("Excel.Application") $oExcel.Visible = 1 ; Let Excel show itself $oExcel.WorkBooks.Add Sleep(2000) Local $hWnd = GUICreate("aa" & $VersionNumber, @DesktopWidth , @DesktopHeight - 45,-1,-1, $WS_MINIMIZEBOX + $WS_SYSMENU + $WS_CLIPCHILDREN) GUICtrlCreateObj($oExcel, -1, -1, @DesktopWidth - 10, @DesktopHeight -75) GUISetState(@SW_SHOW, $hWnd) While WinExists($hWnd) Local $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then GUIDelete() WEnd EndFunc ; Main() Func MyErrFunc() Local $HexNumber=hex($oMyError.number,8) Msgbox(0,"AutoItCOM Test","We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & $HexNumber & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext ) SetError(1); to check for after this function returns Endfunc It shows a COM Error. Can anyone help me in converting word.Document to excel. Many Thanks, Harish
  4. HI , It works. It is basically where I started. The problem is when the Excel is embedded in GUI , I am not able to use any other excels which are previously opened
  5. HI I am sorry to tell this. If I used Excel UDF to open and then attach it inside a GUI . Many Excel macros syntax doesnot work. For eg:) Range.Select too doesn't work if i do in this method
  6. Hi Water, Thanks for the reply. I can use Excel UDF's. But the problem is I need to wrap [The entire excel] inside a Autoit Form GUI. This can only be achieved by using objget . Many Thanks,
  7. Hi Guys, I have the below code which works fine for me but for one problem. It locks the existing already opened excel sheets. Is there a way to use getobject for the below code with new instance of excel so it does not disturb already opened excels. #include <GUIConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> ; ; Embedding an Excel document inside an AutoIt GUI ; ; Limitations: ; ; 1. Integrating the GUI Menu with the Objects Menu does not work. ; (they have seperate menu bars) ; ; Initialize my error handler $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") ;~ $FileName=@ScriptDir & "\Worksheet.xls" $FileName = "C:\Users\Demo.xlsm" $oExcelDoc = ObjGet($FileName, "Excel.Application") ; Get an Excel Object from an existing filename If IsObj($oExcelDoc) Then GUICreate("Embedded ActiveX Test", 640, 580, (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, $WS_MINIMIZEBOX + $WS_SYSMENU + $WS_CLIPCHILDREN) $GUI_ActiveX = GUICtrlCreateObj($oExcelDoc, 1, 95, 400, 300) For $Bar In $oExcelDoc.CommandBars If $Bar.Enabled = True Then $Bar.Enabled = False If $Bar.Visible = True Then $Bar.Visible = False Next $oExcelDoc.Application.DisplayFormulaBar = False $oExcelDoc.Application.CommandBars("Shadow Settings").Visible = False $oExcelDoc.Application.DisplayScrollBars = True $oExcelDoc.Application.DisplayStatusBar = False ControlHide("Embedded ActiveX Test", "", "[CLASS:EXCEL2; INSTANCE:1]") ControlHide("Embedded ActiveX Test", "", "[CLASS:EXCEL2; INSTANCE:2]") GUISetState(@SW_SHOW) ;Show GUI ; GUI Message loop While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ;or $msg = $GUI_FileExit ExitLoop EndSelect WEnd GUIDelete() ; Don't forget to close your workbook, otherwise Excel will stay in memory after the script exits ! $oExcelDoc.Close(0) ; Close the Excel workbook - Save prompt will not open EndIf Exit ; This is my custom error handler Func MyErrFunc() $HexNumber = Hex($oMyError.number, 8) MsgBox(0, "AutoItCOM Test", "We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & $HexNumber & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ ) SetError(1) ; to check for after this function returns EndFunc ;==>MyErrFunc Thanks
×
×
  • Create New...