Start a MACRO If statement true - Word

Mawallace
Mawallace used Ask the Experts™
on
I have a macro in a Word document.

How do I start a macro if a merge filed is a certain value?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
GrahamSkanRetired
Top Expert 2012

Commented:
Sorry Mark,

That isn't possible. You would have to run the merge from VBA, a record at a time, and check the field value before or after the merge for that record and call the macro according to the particular datafield value.

What do you want to do in the macro that would be called? There may be another way to achieve the objective.

Author

Commented:
I would like to delete a section of text if the merge field is true. If the merge field is not true, I do not want the section removed.
GrahamSkanRetired
Top Expert 2012
Commented:
That's OK. Just include the text (in quotes) in the True or False part of an IF test on the MERGEFIELD value.
OWASP: Avoiding Hacker Tricks

Learn to build secure applications from the mindset of the hacker and avoid being exploited.

Author

Commented:
What is it is is two or three paragraphs, with formatting such as tables?

Author

Commented:
Yes - that is right!
GrahamSkanRetired
Top Expert 2012

Commented:
Hi Mark,

Are we to take it that the penny has dropped, and that you have a full understanding of the method?

Graham

Author

Commented:
No - I was trying to make it clearer!

I have  I two or three paragraphs, with formatting such as tables which need including. I would assume this would make the suggested solution of including within an If statement more complicated?
GrahamSkanRetired
Top Expert 2012
Commented:
Not necessarily. The only complication that I can foresee is where there are already quotes embedded in the blocks. You would have to replace them with a { QUOTE 34 } field, otherwise the text block will only display up to the first embedded quote.

Author

Commented:
How do I enter a Quote 34 field?
Retired
Top Expert 2012
Commented:
You can enter a QUOTE field like any other, but you need to add the 34 as 'Literal text'
.
Alternatively, again like any other field, you can enter the field delimiters with Ctrl+F9 and type the text, i.e QUOTE 34, in between them.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial