Jump to content

Trouble with ControlSetText and ControlClick


gypsy
 Share

Recommended Posts

Hi, Need help on the 'save' portion of this script. I've been working on two options to close the word document and save it, but have not been able to get either option to work. Please HELP!

;Include the following Constants:

;=================================

#include <file.au3>

#include <GUIConstants.au3>

#include <Word.au3>

#include <Inet.au3>

#include <Date.au3>

;Declare Global Variables

;========================

;Open a Word document.

$oWordApp2 = _WordCreate(@ScriptDir & "\Test2.doc", 1)

WinActivate("Test2.doc - Microsoft Word", "Test2.doc")

;Write to a Word document.

Send("From The Fringes of Power - 10 Downing Street Diaries 1939-1955 by John Colville ")

Send("The War Begins")

;Close the Word document. Option #1 Could not get this to work.

;============================================

FileSaveDialog("Save As", "@ScriptDir", "Word (*.doc)")

WinWait("Save As", "Save &in", 3)

WinActivate("Save As")

WinWaitActive("Save As")

ControlFocus("Save As", "Save &in", "1")

ControlSetText("Save As", " ", "1148", "Test2")

ControlClick("Save As", "Save &in", "Button1")

;Close the Word document. Option #2 Could not get this to work.

;===========================================

;WinClose("Test2.doc - Microsoft Word")

;WinWait("Microsoft Office Word", "Do you want to save the changes to Test2.doc?", 10)

;WinActivate("Microsoft Office Word", "Do you want to save the changes to Test2.doc?")

;ControlClick("Microsoft Office Word", "&Yes", "[CLASS:Button; TEXT:&Yes; INSTANCE:1]")

Exit

Link to comment
Share on other sites

Hi, Need help on the 'save' portion of this script. I've been working on two options to close the word document and save it, but have not been able to get either option to work. Please HELP!

You started using the Word.au3 UDF, but didn't follow through:

;Include the following Constants:
;=================================
#include <Word.au3>

;Declare Global Variables
;========================
;Open a Word document.
$oWordApp2 = _WordCreate(@ScriptDir & "\Test2.doc", 1)

;Write to a Word document.
$oDoc = _WordDocGetCollection($oWordApp2, 0)
$oDoc.Range.insertAfter("From The Fringes of Power - 10 Downing Street Diaries 1939-1955 by John Colville ")
$oDoc.Range.insertAfter("The War Begins")

;Close the Word document. Option #1 Could not get this to work.
;============================================
_WordDocSaveAs($oDoc, @ScriptDir & "\1148\Test2.doc")

;Close the Word document. Option #2 Could not get this to work.
;===========================================
_WordDocClose($oDoc, -1, 1)

;Close Word
;===========================================
_WordQuit($oWordApp2)

In your original code, I don't think you understood FileSaveDialog(). Read up on it in the help file and play with the example script there. It only returns the selected path, it doesn't actually perform the save.

:P

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...