Jump to content

Microsoft Word in GUI


ajit
 Share

Recommended Posts

Hi,

I have been trying to use ObjCreate to embed MSWord in a GUI without much success.

Could someone share with me a script or a link with MSWord in a GUI.

Thanking in anticipation.

Regards

Ajit

Edited by ajit
Link to comment
Share on other sites

@Wakillon

Thanks for the link. I checked the post. It does not work properly.

Thanks anyway

Regards

Ajit

I modify a little...

#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

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

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...