Jump to content

Recommended Posts

Posted

Hi guys,

Recently starting to use AutoIt and I'm trying to fill in a form I have which in .doc format.

I've tried the following so far but I'm not getting any postive results.

#NoTrayIcon
#include<Word.au3>

$formName = "\form.doc"

$word = ObjCreate("Word.Application")
$word.visible = True
$word.Documents.open($formName)

$word.Selection.Find.Text = "Name:";
$word.Selection.Find.ClearFormatting();

$word.Selection.Find.Replacement.Text = "Name: John";
$word.Selection.Find.Replacement.ClearFormatting();

$word.Selection.Find.Forward = true;
$word.Selection.Find.Execute

Would anyone be able to help? Link to examples of this? I've already looked through the help documents but haven't found anything similar.

Thanks

Posted (edited)

Check the Word management UDF functions in the AutoIt Help files.

In your example, it might look like this:

#include <Word.au3> 

$oWordApp = _WordCreate("", 0, 0)

$oWord = _WordDocOpen($oWordApp, $formName)  

_WordDocFindReplace($oWord, "Name:", "Name: John")

_WordDocSave($oWord)

_WordDocClose($oWord)

_WordQuit($oWordApp)

Edit: made example more complete

Edited by SAG
Posted

Check the Word management UDF functions in the AutoIt Help files.

In your example, it might look like this:

#include <Word.au3> 

$oWordApp = _WordCreate("", 0, 0)

$oWord = _WordDocOpen($oWordApp, $formName)  

_WordDocFindReplace($oWord, "Name:", "Name: John")

_WordDocSave($oWord)

_WordDocClose($oWord)

_WordQuit($oWordApp)

Edit: made example more complete

Thank you. I will try this.

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
  • Recently Browsing   0 members

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