Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Other Office > Word VBA
Word VBA Discuss using VBA to program Word.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Word VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old November 9th, 2013, 03:41 AM
Registered User
Join Date: Nov 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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!
Old December 6th, 2013, 09:00 PM
Friend of Wrox
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts


Have you tried using SendKeys


C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips & Tricks (http://www.vbadud.blogspot.com)

Similar Threads
Thread Thread Starter Forum Replies Last Post
Form Data Will Not Display When I Click On Display Button sprdave BOOK: Beginning C# 3.0 : An Introduction to Object Oriented Programming ISBN: 978-0-470-26129-3 12 February 13th, 2011 12:09 AM
on the click of a button how to load another form? amit_mande@yahoo.com VB.NET 2 September 12th, 2006 06:53 AM
Button Click ~Bean~ ASP.NET 1.0 and 1.1 Basics 2 September 27th, 2005 09:32 AM
creating reports thru a button click on a form clueless_may Access VBA 3 May 13th, 2004 09:34 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.