Sign in to follow this  
Followers 0
LOULOU

Word Embedded in a Gui

14 posts in this topic

Is someone can give me an example on how to embed a new word file in a gui.

Thanks in advance

Share this post


Link to post
Share on other sites



Is someone can give me an example on how to embed a new word file in a gui.

Thanks in advance

This seems to work:

Requirements:

Latest IE.au3

Latest Beta

#include <IE.au3>
#include <GUIConstants.au3>

_IEErrorHandlerRegister ()

$oIE = _IECreateEmbedded()

GUICreate("Embedded Word control Test", 640, 580, (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, _
        $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
$GUIActiveX = GUICtrlCreateObj($oIE, 10, 40, 600, 360)
$GUI_Button_Open = GUICtrlCreateButton("Open File", 10, 420, 100, 30)

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $GUI_Button_Open
            $sFile = FileOpenDialog("Open Word File", @MyDocumentsDir, "Word Doc (*.Doc)")
            If $sFile <> "" Then
                _IENavigate ($oIE, $sFile, 0)
                While $oIE.ReadyState <> 4
                    Sleep(50)
                WEnd
                $oDoc = $oIE.Document
                $oWord = $oDoc.Application
                ; Put document into 'Web View' mode
                $oWord.Activewindow.View = 6
                ; Manage display of toolbars
                $oDoc.CommandBars ("Reviewing").visible = False
                $oDoc.CommandBars ("Standard").Visible = True
            EndIf
    EndSwitch
    Sleep(50)
WEnd

_IENavigate ($oIE, "about:blank")
$oDoc = 0
$oWord = 0

GUIDelete()

Exit

Share this post


Link to post
Share on other sites

Thanks big daddy it's work perfectly

Share this post


Link to post
Share on other sites

Thanks big daddy it's work perfectly

No problem, glad I could help.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

No problem, glad I could help.

Hi,

I am very interested in this topic.. so I tried to run the code and following occoured:

IE asks whether it should open or save the *.doc file. After pressing the open button the wordfile is directly loaded in word. :D

OS= XP SP2 ger.

I have latest IE.au3 and autoit beta.

whats wrong?

greetings mozart90

Edited by mozart90

Share this post


Link to post
Share on other sites

Hi,

I am very interested in this topic.. so I tried to run the code and following occoured:

IE asks whether it should open or save the *.doc file. After pressing the open button the wordfile is directly loaded in word. :D

OS= XP SP2 ger.

I have latest IE.au3 and autoit beta.

whats wrong?

greetings mozart90

To be honest with you I'm not sure, this is what it is looks like for me.

Posted Image

Share this post


Link to post
Share on other sites

To be honest with you I'm not sure, this is what it is looks like for me.

Posted Image

yes that looks what I expected the script to do...

but I get the *.doc file opend in MSWord.

anyone any idea??

greetings mozart90

Share this post


Link to post
Share on other sites

This seems to work:

Requirements:

Latest IE.au3

Latest Beta

#include <IE.au3>
#include <GUIConstants.au3>

_IEErrorHandlerRegister ()

$oIE = _IECreateEmbedded()

GUICreate("Embedded Word control Test", 640, 580, (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, _
        $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
$GUIActiveX = GUICtrlCreateObj($oIE, 10, 40, 600, 360)
$GUI_Button_Open = GUICtrlCreateButton("Open File", 10, 420, 100, 30)

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $GUI_Button_Open
            $sFile = FileOpenDialog("Open Word File", @MyDocumentsDir, "Word Doc (*.Doc)")
            If $sFile <> "" Then
                _IENavigate ($oIE, $sFile, 0)
                While $oIE.ReadyState <> 4
                    Sleep(50)
                WEnd
                $oDoc = $oIE.Document
                $oWord = $oDoc.Application
                ; Put document into 'Web View' mode
                $oWord.Activewindow.View = 6
                ; Manage display of toolbars
                $oDoc.CommandBars ("Reviewing").visible = False
                $oDoc.CommandBars ("Standard").Visible = True
            EndIf
    EndSwitch
    Sleep(50)
WEnd

_IENavigate ($oIE, "about:blank")
$oDoc = 0
$oWord = 0

GUIDelete()

Exit

OK ! EXCELLENT THAT A WORD DOCUMENT IS OPENED ACCORDING TO THE UPPER CODE .

hOW CAN I SAVE THE OPENED DOCUMENT TO RTF FORMAT .....

PLEASE ... ANY BODY .. IDEAS ? SENDING KEYS ??

Share this post


Link to post
Share on other sites

OK ! EXCELLENT THAT A WORD DOCUMENT IS OPENED ACCORDING TO THE UPPER CODE .

hOW CAN I SAVE THE OPENED DOCUMENT TO RTF FORMAT .....

PLEASE ... ANY BODY .. IDEAS ? SENDING KEYS ??

Use this and give it an extension of .rtf.

#include <IE.au3>
#include <GUIConstants.au3>

_IEErrorHandlerRegister()

$oIE = _IECreateEmbedded()

GUICreate("Embedded Word control Test", 640, 580, (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, _
        $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
$GUIActiveX = GUICtrlCreateObj($oIE, 10, 40, 600, 360)
$GUI_Button_Open = GUICtrlCreateButton("Open File", 10, 420, 100, 30)
$GUI_Button_Save = GUICtrlCreateButton("Save File", 120, 420, 100, 30)

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $GUI_Button_Open
            $sFile = FileOpenDialog("Open Word File", @MyDocumentsDir, "Word Doc (*.Doc)")
            If $sFile <> "" Then
                _IENavigate($oIE, $sFile, 0)
                While $oIE.ReadyState <> 4
                    Sleep(50)
                WEnd
                $oDoc = $oIE.Document
                $oWord = $oDoc.Application
                ; Put document into 'Web View' mode
                $oWord.Activewindow.View = 6
                ; Manage display of toolbars
                $oDoc.CommandBars ("Reviewing").visible = False
                $oDoc.CommandBars ("Standard").Visible = True
            EndIf
        Case $GUI_Button_Save
            $sFilePath = FileSaveDialog("Save File", @MyDocumentsDir, "All (*.*)")
            If $sFilePath <> "" Then $oDoc.SaveAs ($sFilePath)
    EndSwitch
    Sleep(50)
WEnd

_IENavigate($oIE, "about:blank")
$oDoc = 0
$oWord = 0

GUIDelete()

Exit

Share this post


Link to post
Share on other sites

Use this and give it an extension of .rtf.

#include <IE.au3>
#include <GUIConstants.au3>

_IEErrorHandlerRegister()

$oIE = _IECreateEmbedded()

GUICreate("Embedded Word control Test", 640, 580, (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, _
        $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
$GUIActiveX = GUICtrlCreateObj($oIE, 10, 40, 600, 360)
$GUI_Button_Open = GUICtrlCreateButton("Open File", 10, 420, 100, 30)
$GUI_Button_Save = GUICtrlCreateButton("Save File", 120, 420, 100, 30)

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $GUI_Button_Open
            $sFile = FileOpenDialog("Open Word File", @MyDocumentsDir, "Word Doc (*.Doc)")
            If $sFile <> "" Then
                _IENavigate($oIE, $sFile, 0)
                While $oIE.ReadyState <> 4
                    Sleep(50)
                WEnd
                $oDoc = $oIE.Document
                $oWord = $oDoc.Application
                ; Put document into 'Web View' mode
                $oWord.Activewindow.View = 6
                ; Manage display of toolbars
                $oDoc.CommandBars ("Reviewing").visible = False
                $oDoc.CommandBars ("Standard").Visible = True
            EndIf
        Case $GUI_Button_Save
            $sFilePath = FileSaveDialog("Save File", @MyDocumentsDir, "All (*.*)")
            If $sFilePath <> "" Then $oDoc.SaveAs ($sFilePath)
    EndSwitch
    Sleep(50)
WEnd

_IENavigate($oIE, "about:blank")
$oDoc = 0
$oWord = 0

GUIDelete()

Exit

Thanks ....

wHAT I WANT TO DO WITH THIS IS JUST TO PICK A FILE WITHOUT A DIALOG and open it in the Gui .

$sFilePath = "file.doc"

and save it directly to

$sFilePathsaved = "file.rtf"

The save dialg does not save in True Rtf format . I can not open the SAVED (RTF)file saved in a simple

RTF Editor . This means , I GUESS , the file must be saved with the Save as dialog in winword .

How i make visible the word menu in the Autoit GUI ?

AND ACCESS THE "SAVE AS" DIALOG .... ?

Share this post


Link to post
Share on other sites

Thanks ....

wHAT I WANT TO DO WITH THIS IS JUST TO PICK A FILE WITHOUT A DIALOG and open it in the Gui .

$sFilePath = "file.doc"

and save it directly to

$sFilePathsaved = "file.rtf"

The save dialg does not save in True Rtf format . I can not open the SAVED (RTF)file saved in a simple

RTF Editor . This means , I GUESS , the file must be saved with the Save as dialog in winword .

How i make visible the word menu in the Autoit GUI ?

AND ACCESS THE "SAVE AS" DIALOG .... ?

IT is a quite smart solution to save text in winword ( doc ) format . But this does not save the text in true RTF FORMAT .

THE CODE .... ONLY THE FILE NAME CJHANGED TO RTF .

$word = ObjCreate("Word.Application")

$word.visible = False

$word.Documents.Add

$word.Selection.TypeText( "this is a " )

$word.Selection.Font.Bold = True

$word.Selection.TypeText( "test" )

$word.Selection.Font.Bold = False

$word.Selection.TypeText( "." )

$word.ChangeFileOpenDirectory( @ScriptDir )

$word.Activedocument.SaveAs( "test.rtf" )

$word.Application.Quit

NOW LOAD THE SAVED RTF FILE BY A SIMPLE EDITOR WHICH SUPPORTS ONLY RTF --- YOU WILL SEE

A GARBAGE .

bUIT IF YOU MODIFY ... BIG DADDYS CODE ... TO ENABLE THE EMBEDED DOCUMENT TO SHOW THE FULL MENY ..

IT IS POSSIBLE TO SAVE THE FILE BY SENDING KEYS TO TO SAVE AS COMMAND I GUESS ....

???????????

Share this post


Link to post
Share on other sites

IT is a quite smart solution to save text in winword ( doc ) format . But this does not save the text in true RTF FORMAT .

THE CODE .... ONLY THE FILE NAME CJHANGED TO RTF .

$word = ObjCreate("Word.Application")

$word.visible = False

$word.Documents.Add

$word.Selection.TypeText( "this is a " )

$word.Selection.Font.Bold = True

$word.Selection.TypeText( "test" )

$word.Selection.Font.Bold = False

$word.Selection.TypeText( "." )

$word.ChangeFileOpenDirectory( @ScriptDir )

$word.Activedocument.SaveAs( "test.rtf" )

$word.Application.Quit

NOW LOAD THE SAVED RTF FILE BY A SIMPLE EDITOR WHICH SUPPORTS ONLY RTF --- YOU WILL SEE

A GARBAGE .

bUIT IF YOU MODIFY ... BIG DADDYS CODE ... TO ENABLE THE EMBEDED DOCUMENT TO SHOW THE FULL MENY ..

IT IS POSSIBLE TO SAVE THE FILE BY SENDING KEYS TO TO SAVE AS COMMAND I GUESS ....

???????????

1st pry that key off your keyboard that says "Caps Lock", might help you get more help.


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

1st pry that key off your keyboard that says "Caps Lock", might help you get more help.

I did that ! Nothing Happns :D

Share this post


Link to post
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
Sign in to follow this  
Followers 0