LOULOU Posted July 5, 2006 Share Posted July 5, 2006 Is someone can give me an example on how to embed a new word file in a gui. Thanks in advance Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted July 5, 2006 Moderators Share Posted July 5, 2006 Is someone can give me an example on how to embed a new word file in a gui. Thanks in advanceThis seems to work: Requirements: Latest IE.au3 Latest Beta expandcollapse popup#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 Link to comment Share on other sites More sharing options...
LOULOU Posted July 5, 2006 Author Share Posted July 5, 2006 Thanks big daddy it's work perfectly Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted July 5, 2006 Moderators Share Posted July 5, 2006 Thanks big daddy it's work perfectlyNo problem, glad I could help. Link to comment Share on other sites More sharing options...
mozart90 Posted July 10, 2006 Share Posted July 10, 2006 (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. OS= XP SP2 ger.I have latest IE.au3 and autoit beta.whats wrong?greetings mozart90 Edited July 10, 2006 by mozart90 Easy Zip Compression using XP Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted July 10, 2006 Moderators Share Posted July 10, 2006 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. OS= XP SP2 ger.I have latest IE.au3 and autoit beta.whats wrong?greetings mozart90To be honest with you I'm not sure, this is what it is looks like for me. Link to comment Share on other sites More sharing options...
mozart90 Posted July 11, 2006 Share Posted July 11, 2006 To be honest with you I'm not sure, this is what it is looks like for me.yes that looks what I expected the script to do... but I get the *.doc file opend in MSWord.anyone any idea??greetings mozart90 Easy Zip Compression using XP Link to comment Share on other sites More sharing options...
lukeneo Posted July 22, 2006 Share Posted July 22, 2006 This seems to work: Requirements: Latest IE.au3 Latest Beta expandcollapse popup#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 ?? Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted July 22, 2006 Moderators Share Posted July 22, 2006 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. expandcollapse popup#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 Link to comment Share on other sites More sharing options...
lukeneo Posted July 23, 2006 Share Posted July 23, 2006 Use this and give it an extension of .rtf. expandcollapse popup#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 .... ? Link to comment Share on other sites More sharing options...
GaryFrost Posted July 23, 2006 Share Posted July 23, 2006 http://www.autoitscript.com/forum/index.ph...amp;#entry82172 SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
lukeneo Posted July 23, 2006 Share Posted July 23, 2006 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.QuitNOW 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 ....??????????? Link to comment Share on other sites More sharing options...
GaryFrost Posted July 23, 2006 Share Posted July 23, 2006 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.QuitNOW 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. Link to comment Share on other sites More sharing options...
lukeneo Posted July 23, 2006 Share Posted July 23, 2006 1st pry that key off your keyboard that says "Caps Lock", might help you get more help.I did that ! Nothing Happns 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