Click a button on a form programmatically
Dear wise ones
I have two macro enabled templates, producing documents in landscape and portrait orientation respectively. Each template has two forms. The first is a disclaimer form and is loaded by the autonew function on the templates, the second form (which is the main data entry form) loads when the OK button is clicked on the disclaimer. The disclaimer also contains a cancel button which unloads the form.
The templates produce documents (medication lists for patients) and usually only a landscape OR a template version will be required (the landscape version hold a little more information about the medications, the portrait version is more of a simple list). Occasionally however, people in the organisation will want to produce BOTH a landscape and a portrait version. To prevent them having to repeat the process of data entry twice, I have placed an option button on the main data entry form that will enable this. So far so good.
My problem is that if a person working in (say) the portrait template also wants a landscape document and checks the option button to do this, the section of the subsequent code that will open the second document:
Documents.add Templates:= ...........
Will cause the autonew macro to fire on the template and for the disclaimer form to open on the second document. I want to stop this happening.
In a nutshell therefore, what I want to do is to programmatically click the cancel button on the disclaimer form when it opens so that the user never sees the disclaimer form at all.
Working in Word 2010.
My first post, and looking forward to your assistance. Thanks everyone!