Skip to content
This repository has been archived by the owner on Apr 16, 2022. It is now read-only.

Mergefield does not work with if statement #52

Open
chlab opened this issue Jun 12, 2018 · 1 comment
Open

Mergefield does not work with if statement #52

chlab opened this issue Jun 12, 2018 · 1 comment

Comments

@chlab
Copy link

chlab commented Jun 12, 2018

Expected Behavior

I am trying to use a merge field in an if condition. Ideally, the condition would be evaluated during the mail merge(?). This would make mailmerge templates much more flexible.

My intended use-case is to check a checkbox depending on a placeholder value.

Note: if there is another way to do this (check a checkbox) please let me know!

Current Behavior

The if expression is not evaluated.

Steps to Reproduce

Add a merge field and wrap it in an if condition:

{ IF { MERGEFIELD toggle_test } = "True" "Yes" "No" }

Merge the template as follows:

from mailmerge import MailMerge

with MailMerge('merge_template.docx') as document:
    document.merge(
        toggle='True'
    )

    document.write('merge_output.docx')

Your Environment

  • Python version: 3.4.2
  • docx-mailmerge version: 0.4.0
  • Word for Mac Version 16
@faiyeah
Copy link

faiyeah commented Oct 25, 2018

Unsure if I am correct or not.

It seems "toggle='True'" should be written as "toggle_test='True'".

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants