falconv Posted May 13, 2005 Share Posted May 13, 2005 I'm trying to use AutoIt to edit/make .doc files. Pretty much all I need is to have a little section bolded, but also the output file needs to be in .doc format. Is there a way to do this? Without opening M$ Word itself. I'd like to be able to do it in a GUI window. I haven't figured out how to use DllCall yet, will that help me at all? Thanks in advance. Link to comment Share on other sites More sharing options...
DaleHohm Posted May 14, 2005 Share Posted May 14, 2005 I'm trying to use AutoIt to edit/make .doc files. Pretty much all I need is to have a little section bolded, but also the output file needs to be in .doc format. Is there a way to do this? Without opening M$ Word itself. I'd like to be able to do it in a GUI window. I haven't figured out how to use DllCall yet, will that help me at all? Thanks in advance.<{POST_SNAPBACK}>Are you saying you don't want to OPEN Word or that you don't HAVE Word? If you don't have it it is obviously much more complicated and would depend on the version of Word and other issues.If you have Word and just don't want to work inside its GUI, I'd suggest that you look into the new V3.1.1++ from the developer forum and use the ObjCreate COM function and use the Word object model to open a document without making it visible, make your changes and then save it back out again.Dale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble Link to comment Share on other sites More sharing options...
falconv Posted May 16, 2005 Author Share Posted May 16, 2005 Sorry for the delayed response, wasn't online over the weekend. Yes, I have word, I just want to be able to keep my script all-inclusive (so the user doesn't have to bother with editing in Word, and then switching back to the script). The easier (rather, "dumber," no offense) the better I'll download 3.1.1 now and research the ObjCreate COM function. Is there documentation on this already? or will I need to ask a lot of questions in the developer forum? Thanks again! Link to comment Share on other sites More sharing options...
DaleHohm Posted May 16, 2005 Share Posted May 16, 2005 There is COM interface documentation in the Help file and there is a lot of discussion and examples being shared in the Developer forum. Please note that the COM interface simply lets you access the application-specific functionality through its API... you'll want to check out MSDN and books on Office VBA etc. for the gory details. Most examples you find in VBSctipt or VBA can readily be translated into AutoIt. Dale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble Link to comment Share on other sites More sharing options...
falconv Posted May 27, 2005 Author Share Posted May 27, 2005 Well, it took me nearly two weeks, but I finally think I'm beginning to grasp the concepts here!I was able to successfully create a new word document, have it type some text, some in normal some in bold, save the file, and exit the program. I've done it both while watching, and hidden. It's quite nice Here's an example of my script, for anyone else wanting to learn how to control Word documents, or other ObjCreate capable programs:$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( @DesktopDir ) $word.Activedocument.SaveAs( "test.doc" ) $word.Application.QuitAnd if you want to watch, just change $word.visible = False to TrueA great way to get the commands is to use Word (or Excel, or whatever program you're using) to create a macro, copy/paste it, put $word. before the commands (or whatever your string is called). It takes some cropping, and a lot of adjusting (and it took me a long time to figure out what to replace, ie for $word.Selection.Font.Bold, it was originally wdToggle, it took a while to figure out that it's either True or False).Does anyone know if there's a list somewhere I can find the commands, and maybe even short descriptions of them? so I can create from scratch rather than making a macro and ripping/translating.Also, is there anything like this for Outlook? Sorry to change topic a little, but I'd imagine Outlook would have something similar, but it doesn't have a Macro Record option, so I can't make macros and try to translate them or anything.Thanks again for all the help! This program just keeps getting cooler and cooler! Link to comment Share on other sites More sharing options...
DaleHohm Posted May 27, 2005 Share Posted May 27, 2005 Nice job!You've opened the door to brand new possibilities...Regarding the application enumerations (e.g. wdToggle) see here:Get Enumerated constants...Regarding the object models for other office applications, go to http://www.msdn.com and search for "Outlook.Application" to find the object model for Outlook and other applications. Google for CreateObject("Outlook.Application") to find lots of other examples and discussions.Dale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble 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