Closed dwasyl closed 2 months ago
After some additional testing, the error seems to occur when the merge fields are located in a table cell. When the fields are moved outside of the table, there is no problem at all.
Any idea why this would cause a problem?
I'll have a look into it, can you provide a sample docx so that I can reproduce the error ?
@iulica Sure, here you go. Doc merge table simple sample.docx
Oh, I now noticed you are using the 0.6.3 version, that's quite old. Would you care testing it with the latest version ? Your document seems to work fine for me.
Ok, I could reproduce it myself.
The problem was an empty field (I created it by pressing alt-f9) or something like this. It doesn't matter where it is, in a table or not. Your document didn't have it so it worked fine.
For the moment, you'll have to find this empty field and delete it from the document. You can see the fields by pressing ctrl-f9 or something like this, I have a mac and it works by pressing option-f9.
I will fix this in the next release, but for the moment it's not critical.
I included a fix and released it with 0.8.2
Great find! I hadn't even noticed that, but makes sense why it would cause that error.
Appreciate the fix so quickly!
Hi there,
I have a particular docx file that I'm trying to use for a merge, but I keep getting a
list index out of range
error related to_get_field_type
(specifically line 393return s[0], s[1:]
whereinstr
is an empty string. Presumably an empty string shouldn't even be able to get to this point, so there's probably some error checking that's missed along the way.I'm running into this when I run
doc = MailMerge(file, remove_empty_tables=False, auto_update_fields_on_open="no")
so that I can rundoc.get_merge_fields()
.I've tried going through the code base a bit to try and figure out the error, but clearly there is something about the way it's processing the source
docx
file that's causing this and just wondering if there were any initial ideas as to what might cause this problem. As it stands, I can't figure out it out enough to check for the issue in advance.For reference, it's running Python 3.9.6, and
docx-mailmerge2
version 0.6.3.