sigil Posted May 2, 2008 Posted May 2, 2008 The following code should open a Word document selected by the user, and that document should end up being the active window. #include <word.au3> $path=fileopendialog("Choose File",@desktopdir,"Word Documents (*.doc)") $wObj=_wordcreate($path) $wWin=wingethandle($wObj) winactivate($wWin) winwaitactive($wWin) What actually happens is this: the document opens and is the foremost window, but it is grey on the top, i.e., not active. What can I do to make the document end up being active?
MikeP Posted May 3, 2008 Posted May 3, 2008 (edited) #include <word.au3> Opt("WinTitleMatchMode", 2) $path=fileopendialog("Choose File",@desktopdir,"Word Documents (*.doc)") $wObj=_wordcreate($path) $wWin=wingethandle($wObj) winactivate("Word") winwaitactive("Word") quick answer.. maybe not the best since i'm using string file name and you're using handles which isn't pretty..but at least it does what you want Edited May 3, 2008 by MikeP
sigil Posted May 6, 2008 Author Posted May 6, 2008 :BUMP: I still haven't been able to get this to work. MikeP, I can't use your solution because it doesn't work properly if I have another window with the word "Word" in its title. I'm getting a confusing result when I test the data in $wObj. With this code: #include <word.au3> $path=fileopendialog("Choose File",@desktopdir,"Word Documents (*.doc)") $wObj=_wordcreate($path) $wWin=WinGetTitle($wObj) msgbox(0,"",$wWin) winactivate($wWin) winwaitactive($wWin) the MsgBox() shows the path for the script that I'm running, not the Word doc that I chose with FileOpenDialog().
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