Jump to content
megashape

Help with a script - Repeating OK click

Recommended Posts

megashape

Hi there,

I wanted to ask for general guidelines to help me understand how to create a script with AutoIT with my specific example.
I have a mail merge that I need to run in Word Office and at the end, it triggers hundreds of file conversion windows on which I have to click OK in every single one.

I'm sure this can be easily automated but I have no experience with AutoIT just some basic JS, could you please guide me at the right tutorials or explain the logic to me?

Thank you.

Share this post


Link to post
Share on other sites
Earthshine

Word and all office apps have VBA built in and it can EASILY do this.

Private Sub Document_Open() 
    DoMailMerge 
End Sub 
 
Public Sub DoMailMerge() 
    Dim DocName$ 
    DocName = ActiveDocument.Name 
     'Do mailmerge
    With ActiveDocument.MailMerge 
        .Destination = wdSendToNewDocument 
        .Execute 
    End With 
     'Close mailmerge document
    Windows(DocName).Close wdDoNotSaveChanges 
End Sub

http://www.vbaexpress.com/kb/getarticle.php?kb_id=122

  1. Copy the code above.
  2. Open the MailMerge document.
  3. Hit Alt+F11 to open the Visual Basic Editor.
  4. Double-click Project Normal at the left.
  5. Choose Insert-Module, and paste the Public Sub code into the window at the right.
  6. Hit the Save diskette button and close the VBE.
  7. Double-click the MailMerge Project at the left.
  8. Double-click MicrosoftWordObjects.
  9. Double-click ThisDocument
  10. Paste the Private Sub code into the window at the right.
  11. Hit the Save diskette button and close the VBE.
  12. To edit the document or the code, hold down Shift when opening the document to prevent the macro from running
 

 

Test the code:

 

  1. Close and reopen the mailmerge document. A new FormLetters document should be created containing the merged information

if you just have to use AutoIt to click the buttons you can do that using the Send command pretty easily enough though. Use the AutoIt Info Tool to get the button you want to press and we can help.

Edited by Earthshine

My resources are limited. You must ask the right questions

 

Share this post


Link to post
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

×