Einhugur Word Plugin: Issue with doc.ApplyFieldData


If I understand it doc.ApplyFieldData is basically a global search and replace so should replace all instances of the target.

I created a bunch of work docs with several values to be replaced which are repeated multiple times (I’m using it to print labels)

The following code Almost works … (2019R1.1 so API 1 on a Mac 12.6.5 Word Plugin V2)

Dim doc as Document = Document.Open(template)

doc.ApplyFieldData("@CustID", ProdName)
doc.ApplyFieldData("@2CustID", ProdName2)
doc.ApplyFieldData("@ProdForm", PrdFormStr )

doc.ApplyFieldData("@ProdID", ProductID)
doc.ApplyFieldData("@LotNo", LotNo)
doc.ApplyFieldData("@ProdTemp",  PrdStoreTemp)

doc.ApplyFieldData("@TempSmp",  SmpTemp )
doc.ApplyFieldData("@SmpForm",  SmpForm )

V = Microseconds
PgList.Append SpecialFolder.Temporary.Child("Pg "+ str(PgList.Ubound + 2) + "  "+ V.StringValue +".docx")

Everything work as expected replacing all the repeated fields EXCEPT
doc.ApplyFieldData(“@SmpForm”, SmpForm )
For that it only replaces the first instance of @SmpForm in the document.

I tried changing the order of the ApplyFieldData Statements and it made no difference … only one entry is replaced regardless.

In this a bug?


Its not a search and replace in the sense that would happen inside word. Since this one goes through the elements, and works on them.

So what can happen is that you could have formatting (without knowing it in the keyword) which splits it into 2 elements, making the search not find it. Thats the most common reason for it not being found.

I think you can turn on show invisible in the Word document to check. (or unzip the word file and look for the keyword and see if it gets split into 2 elements due to formatting)

I opened the Word Doc in BBedit which let me get at the XML… This is the line:


Its looks like @SmpForm is one element to me, yet it’s not replaced!

  • Karen

By all means send us example in our support system if you think there is bug.

That is the most efficient way to get bug taken care of.




I managed to solve the Previous issue (not sure how!) but updating to the latest Word Plugin caused an error.

By the docs it is supposed to be supported on 2019R1.1, but when I try running I get a complier error:

Message: There is no class with this name.
File: Einhugur Word Plugin
Location: Paragraph.Runs
Code: RunIterator

I’m on 2019r1.1 MacOS 12.6.5 Intel

  • Karen

The plugin is not supposed to register iterators at all on 2019r.1.1

I will have it checked. Maybe only snuck in somewhere.

Its been fixed now, the 2019r1 build issue.