Jump to content

How to insert(replace) text into a word document textbox?


 Share

Recommended Posts

Thansk.
I only included functions that would be used by many users or which provide an additional benefit (like hiding complexity).
Soem functions which were simply a wrapper around a single Word method have been removed when I re-wrote the Word (and Excel) UDF.
The wiki provides some detailed information about the UDF.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

  • 1 year later...

Having the FindReplace function  find in headers and footers and textboxes would really make the UDF complete :)

Here is the code, I found from other users, just in case someone needs it.


   ; select the first header on the first page ONLY
   $oDoc.Sections(1).Headers(2).Range.Select()
   ; replace text in first page header
   _Word_DocFindReplace($oDoc, "find-me", "replaced-text", 2, -1)

 

    ; select all other headers BUT not the first page header

   $oDoc.Sections(1).Headers(1).Range.Select()
   ; replace text
   _Word_DocFindReplace($oDoc, "find-me", "replaced-text", 2, -1)

 

Link to comment
Share on other sites

I will think about this as soon as I find some spare time. But please do not hold your breath ;) 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Thanks  for considering Water :)

i cant replace text in textboxes, shapes yet, but im good for now so no rush but I do really think having a function to replace text any where in the doc would really complete the UDF  most jobs would just need a template setup then have keywords replaced and saveas new doc. done.   

Link to comment
Share on other sites

I did a quick check on this issue. _Word_DocFindReplace already supports changing text in headers etc. by passing the relevant range as parameter $vSearchRange.

_Word_DocFindReplace($oDoc, "test", "****", $WdReplaceAll, $oDoc.Sections(1).Headers(1).Range)

 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

I was hoping for the function to work without adding the range, the UDF func would just search all headers, objects and shapes... but hats awesome already.  I try to do it for text-boxes and shapes and see how I go...

Thanks Water!

Link to comment
Share on other sites

This article pretty goods describes your Problem (headers, text boxes ...) and offers a macro to solve your problem.
Translating it to AutoIt is quite simple ;) 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

On 21/04/2017 at 9:54 PM, water said:

This article pretty goods describes your Problem (headers, text boxes ...) and offers a macro to solve your problem.
Translating it to AutoIt is quite simple ;) 

link please?  better yet is there a simple to follow tutorial on how to translate vba macros to autoit? :( i saw heaps of vba examples but just couldn't convert them. 

Link to comment
Share on other sites

On 24/4/2017 at 10:22 AM, Subz said:

I wrote a function for someone else, replacing text in "Text Boxes" that might help: 

 

Very nice, thank you Subz !   I might just pick the looping all ranges part and add to my current code. :D 

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...