neypro

_word_DocFindReplace

9 posts in this topic

can you help me!!!!
I use the _Word_DocFindReplace function in word.au3 to replace the word, when I use it for the paragraph it works well.
But do not substitute words written in the text box

Share this post


Link to post
Share on other sites



Welcome to AutoIt and the forum!

Can you please post the script you run?

1 person likes this

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
18 minutes ago, water said:

Welcome to AutoIt and the forum!

Can you please post the script you run?

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <word.au3>
Local $msg
GUICreate("My Program", 200, 200, -1, -1, -1, $WS_EX_ACCEPTFILES)
$button=GUICtrlCreateButton("drag here",10,10,150,150)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
GUICtrlSetState(-1, $GUI_DROPACCEPTED)
GUISetState(@SW_SHOW)
While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_DROPPED Then
        $nhap=@gui_DragFile
        ExitLoop
    EndIf
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
GUIDelete()

Local $oWord = _Word_Create()
Local $oDoc = _Word_DocOpen($oWord, $nhap, Default, Default, True)
_Word_DocFindReplace($oDoc, "test document", "hiuhiuhiu",$WdReplaceAll)
_Word_DocSaveAs($oDoc, @ScriptDir&"\finis.doc")
_Word_Quit($oWord)

Share this post


Link to post
Share on other sites

2.png

Share this post


Link to post
Share on other sites

A possible solution has been posted here:

 

1 person likes this

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
7 hours ago, water said:

A possible solution has been posted here:

 

I have seen some related posts. But I'm not good at English so I do not understand much :(((

Share this post


Link to post
Share on other sites

The following example processes all text box shapes

#include <Word.au3>
$oWord = _Word_Create()
$oDoc = _Word_DocOpen($oWord, @ScriptDir & "\test.docx")
Global Const $msoTextBox = 17 ; Text box
For $oShape In $oWord.ActiveDocument.Shapes
    If $oShape.Type = $msoTextBox Then
        $oShape.Select
        _Word_DocFindReplace($oDoc, "FindMe", "ReplaceMe", Default, -1)
    EndIf
Next

 

1 person likes this

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
3 hours ago, water said:

The following example processes all text box shapes

#include <Word.au3>
$oWord = _Word_Create()
$oDoc = _Word_DocOpen($oWord, @ScriptDir & "\test.docx")
Global Const $msoTextBox = 17 ; Text box
For $oShape In $oWord.ActiveDocument.Shapes
    If $oShape.Type = $msoTextBox Then
        $oShape.Select
        _Word_DocFindReplace($oDoc, "FindMe", "ReplaceMe", Default, -1)
    EndIf
Next

 

 Oh, thank you. You helped me a lot

Share this post


Link to post
Share on other sites

:) 

1 person likes this

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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