Word - Skipping over a section of a form

Asked By ronbe on 22-Dec-09 06:51 AM
Version: 2004
Operating System: Mac OS X 10.4 (Tiger)
Processor: Intel

My previous post on this problem seems to have terminated. I am still stuck on this. I have simplified the issue as follows:  The form has several form fields.  Interposed between these form fields is a question asking:  Check the box if you want to skip the next field (and go on to a field further down)? <br><br>The checkbox is set to run the macro below on exit.  I assume that placing an X in the box triggers the Exit macro, but that does not seem to work.  This is the macro code: <br><br>If Check1 = True Then <br>
 'skip over Text3 and go to Text4 <br>
  Selection.GoTo What:=wdGoToBookmark, Name:="Text4" <br>
Else <br>
  'checkbox not checked; do not skip over Text3 <br>
  Selection.GoTo What:=wdGoToBookmark, Name:="Text3" <br>
End If <br><br>Comment re the above exit macro: <br>
The macro above was set to run on Exit with the intent that the If?.Then statement would test the value of the checkbox and trigger skipping over the next section of the form if the checkbox is checked by hitting the space bar.  However, this did not happen. The insertion moves into the next section of the form anyway rather than skipping over it. <br><br>(When I click on VB Help I get a message that the Help file cannot be found so I am hoping that the forum can help with this problem.  Thanks.) <br><br>Ron


Jim Gordon Mac MVP replied to ronbe on 22-Dec-09 07:42 PM
Clicking in the box to place the X does not trigger the macro. Pressing
the TAB key to move to the next form field triggers the macro.

-Jim

--
Jim Gordon
Mac MVP
Co-author of Office 2008 for Mac All-in-One For Dummies
http://tinyurl.com/Office-2008-for-Dummies
John McGhie replied to ronbe on 22-Dec-09 03:41 PM
Hi Ron:

You are still coding "If Check1 = True"

It always will be True, because Check1 is the checkbox control itself.  That
contains something (a checkbox) so it is value is NOT "nothing" and
therefore, is true always.

You need to say "If Check1.Value = True then" which tests the Value property
that Check1 contains.  That will toggle between True and False depending on
what the user does.  Check1 has several other properties as well: for
example, its name.  But there is only one .Value.

Did you look at the examples I referred you to?

Cheers


On 22/12/09 10:51 PM, in article 59baf976.-1@webcrossing.JaKIaxP2ac0,


This email is my business email -- Please do not email me about forum
matters unless you intend to pay!

--

John McGhie, Microsoft MVP (Word, Mac Word), Consultant Technical Writer,
McGhie Information Engineering Pty Ltd
Sydney, Australia. | Ph: +61 (0)4 1209 1410
+61 4 1209 1410, mailto:john@mcghie.name
ronbe replied to ronbe on 23-Dec-09 07:09 AM
''' <br>
vChk = ActiveDocument.Bookmarks("Check1").value <br><br>this did not work either. <br><br> I have tried many different permutations of the statements in this macro and have yet to get it to work.  I have looked at a VBA for Dummies book (am feeling very much like a dummy) but it seems more oriented to Office applications for Windows rather than the Mac. I have the impression that VBA Office for the Mac is a somewhat different flavor.  I do not seem to have the VB help files installed and I will have to find the CD.  So, still no luck. <br><br>Still pluggine away here... <br>
ronbe replied to ronbe on 23-Dec-09 07:11 AM
Jim Gordon Mac MVP replied to ronbe on 23-Dec-09 11:27 PM
Hi Ron,

When you are in the VB Editor the help files that are available are
different from when you are not int he VB editor. Here is a slight
modification of your code blended with the example provided by the Help
in the VB Editor. This code works when I press the Tab key while the
form is protected for forms. The default setting for Check1 is not
checked (set this in the form's dialog box before protecting the form).
Adjust the true/false logic as desired. I used different bookmark names
from yours for no reason in particular - just felt like it.

Sub HandleCheckbox()
Dim Check1, Same, MyField
Set MyField = ActiveDocument.FormFields("Check1").CheckBox
If MyField.Default = MyField.Value Then Same = True
If Same = True Then
'skip over Text3 and go to Text4
Selection.GoTo What:=wdGoToBookmark, Name:="FirstBookmark"
MsgBox "FirstBookmark selected"
Else
'checkbox not checked; do not skip over Text3
Selection.GoTo What:=wdGoToBookmark, Name:="SecondBookmark"
MsgBox "SecondBookmark selected"
End If
End Sub

-Jim

--
Jim Gordon
Mac MVP
Co-author of Office 2008 for Mac All-in-One For Dummies
http://tinyurl.com/Office-2008-for-Dummies
John McGhie replied to ronbe on 23-Dec-09 03:36 PM
Hi Ron:

Flip me a copy of the document you are working in, and the template you have
the macro in.  I will take a look for you.  Email in the .sig

(not:  Plain text email with attachments: no urls or you will not make it
through the spam filter...)

You're getting "out of context" errors which means you either have the macro
in the wrong place, or defined as Private when it should be Public.

VBA in Word is VBA in Word, regardless of the platform.  it is just that not
all of it "works" on the Mac (but it is supposed to...)

Cheers

On 23/12/09 11:09 PM, in article 59baf976.2@webcrossing.JaKIaxP2ac0,
ronbe replied to ronbe on 28-Dec-09 10:27 AM
Jim, <br>
I finally got your code snippet to work, once I got the checked-unchecked logic squared away. <br><br>Thanks, <br>
Ron