taurus905 Posted October 21, 2006 Share Posted October 21, 2006 I am using COM to read an Excel spreadsheet and then write to a Word document. I have two questions: 1) How can I ensure that all Excel and Word applications are closed before my script runs? and 2) How can I hide Word from opening on my screen while it is being written to? Thank you in advance for any ideas. I just started using COM and love how AutoIt utilizes it. Just another great example of why AutoIt is so useful. taurus905 "Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs Link to comment Share on other sites More sharing options...
Valuater Posted October 21, 2006 Share Posted October 21, 2006 maybe... ; you may need to get the location from the registry Run("C:\Program Files\Microsoft Office\Office\WINWORD.EXE", @WorkingDir, @SW_HIDE) Sleep(5000) If ProcessExists("WINWORD.EXE") Then MsgBox(64,"Test", "The process - Winword exists", 5) ProcessClose("WINWORD.EXE") EndIf can give ideas 8) Link to comment Share on other sites More sharing options...
taurus905 Posted October 21, 2006 Author Share Posted October 21, 2006 maybe... ; you may need to get the location from the registry Run("C:\Program Files\Microsoft Office\Office\WINWORD.EXE", @WorkingDir, @SW_HIDE) Sleep(5000) If ProcessExists("WINWORD.EXE") Then MsgBox(64,"Test", "The process - Winword exists", 5) ProcessClose("WINWORD.EXE") EndIf can give ideas 8)Valuater, Your solution looks very promising and it does give me some ideas. I will give it a try later today and let you know what I discover. Thanks for your input. taurus905 "Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs Link to comment Share on other sites More sharing options...
Locodarwin Posted October 24, 2006 Share Posted October 24, 2006 2) How can I hide Word from opening on my screen while it is being written to?Thank you in advance for any ideas.I just started using COM and love how AutoIt utilizes it.Just another great example of why AutoIt is so useful.taurus905To answer the second question, assuming you opened your Word object like this:$oWord = ObjCreate("Word.Application")...which starts a Word application object, you'd just make it invisible with a call like this:$oWord.Visible = FalseNow, provided you are using a Word COM method such as .TypeText with your object, and not an AutoIt Send(), you should be fine to write to it to your heart's content.-S (Yet Another) ExcelCOM UDF"A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly...[indent]...specialization is for insects." - R. A. Heinlein[/indent] Link to comment Share on other sites More sharing options...
taurus905 Posted October 29, 2006 Author Share Posted October 29, 2006 To answer the second question, assuming you opened your Word object like this:$oWord = ObjCreate("Word.Application")...which starts a Word application object, you'd just make it invisible with a call like this:$oWord.Visible = FalseNow, provided you are using a Word COM method such as .TypeText with your object, and not an AutoIt Send(), you should be fine to write to it to your heart's content.-SLocodarwin,Thank you for pointing out the$oWord.Visible = FalseThat is what I found after I made this post.My current problem is how to write a link to a word document that will open a web page when it's clicked on..TypeURL("http://www.autoitscript.com").TypeHyperlink("http://www.autoitscript.com")would be nice.Do you know how to do this?taurus905 "Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs Link to comment Share on other sites More sharing options...
Locodarwin Posted October 29, 2006 Share Posted October 29, 2006 Do you know how to do this? taurus905 Select your range (if desired) and then use the .Add() method of the Hyperlinks collection, like this: $oWord.Activedocument.Hyperlinks.Add($oWord.Selection.Range, "http://www.autoitscript.com", _ Default, "Screentip (The hover text)", "Text To Display Link As") The code above will create a hyperlink to www.autoitscript.com, replacing whatever range is currently selected. If no range is currently selected, then the hyperlink will be inserted at the current "cursor" location. The "Default" parameter that I've tossed in is for specifying the sub address. It's a variant, if you decide to specify it. Do not alter the first parameter; an object is expected there, and although this method would normally accept a "Null" or "Nothing" argument, the dev team is still working on a fix that will allow you to skip over object parameters with "Default" or some other as-yet-to-be-determined keyword. I welcome any other MS Office COM automation questions. -S (Yet Another) ExcelCOM UDF"A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly...[indent]...specialization is for insects." - R. A. Heinlein[/indent] Link to comment Share on other sites More sharing options...
taurus905 Posted October 30, 2006 Author Share Posted October 30, 2006 Locodarwin, Thank you very much for the clear explanation and example. It works beautifully. I am sure I will have a few more questions for you in the future because I am finding COM to be very useful. taurus905 "Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted October 30, 2006 Moderators Share Posted October 30, 2006 What is wrong with _WordDocAddLink()? Link to comment Share on other sites More sharing options...
Locodarwin Posted October 30, 2006 Share Posted October 30, 2006 What is wrong with _WordDocAddLink()? Nothing at all - if you're aware of its existence.-S (Yet Another) ExcelCOM UDF"A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly...[indent]...specialization is for insects." - R. A. Heinlein[/indent] 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