Results 1 to 12 of 12
  1. #1
    mallen1
    Guest

    Word Forms (Word 2000)

    I can intercept NextCell and PrevCell commands in a Word form that is divided into protected and unprotected sections. However, when the FIRST field of a protected section is selected and I back tab, the PrevCell command does not work. The shift + tab takes the cursor to the section break, instead of to the beginning of the previous unprotected section as is indicated in the PrevCell code. I contacted Microsoft support and they seem to think that Shift + Tab is being combined with another reserved command in that instance. Do you have any ideas or work arounds for this scenario?

  2. #2
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Word Forms (Word 2000)

    Anything of any use in <A target="_blank" HREF=http://www.wopr.com/cgi-bin/w3t/showthreaded.pl?Cat=&Board=wrd&Number=29329&page=& view=&sb=&o=&vc=1#Post29329>this thread</A>?

  3. #3
    Silver Lounger Charles Kenyon's Avatar
    Join Date
    Jan 2001
    Location
    Sun Prairie, Wisconsin, Wisconsin, USA
    Posts
    2,049
    Thanks
    124
    Thanked 119 Times in 116 Posts

    Re: Word Forms (Word 2000)

    I'm not sure that there is a NextCell or PrevCell command in Word VBA. If there is, it refers to table cells rather than form fields. The F11 and Shift-F11 keys will move from field to field but only in a document that isn't protected for forms.

    What happens is that the Tab and Shift-Tab take you to the next / previous area to type in a protected form when you are in a protected section. When you are in an unprotected section, not in a table, the tab (and shift-tab) key inserts a tab character.

    Because of their function in dialog boxes, I'm not sure that you can even reprogram these keys within Word. I can't assign them to anything in the keyboard customization dialog (whether in a protected form or not). You might check in the vb/vba forum to see if someone there has any ideas.

    When you say that you can intercept the NextCell and PrevCell commands, what exactly is it that you are doing? Could you post the vba code that you are using?
    Charles Kyle Kenyon
    Madison, Wisconsin

  4. #4
    mallen1
    Guest

    Re: Word Forms (Word 2000)

    Many thanks for the sample code. I will try it in my form to see if it works and will be back in touch. For the gentleman who requested the code where I've intercepted Word's "NextCell" and "PrevCell", here is a sample:
    Sub NextCell()
    Selection.Move Unit:=wdSection
    End Sub

    Sub PrevCell()
    If ActiveDocument.ProtectionType <> wdNoProtection Then ActiveDocument.Unprotect

    If Selection.Sections.First.Index = 2 Then
    Selection.GoTo What:=wdGoToBookmark, Name:="bkSupervisor"
    End If

    If Selection.Sections.First.Index = 4 Then
    Selection.GoTo What:=wdGoToTable, Which:=wdGoToFirst, Count:=2, Name:=""
    End If
    If Selection.Sections.First.Index = 5 Then
    Selection.GoTo What:=wdGoToTable, Which:=wdGoToFirst, Count:=4, Name:=""
    End If
    If Selection.Sections.First.Index = 6 Then
    Selection.GoTo What:=wdGoToBookmark, Name:="bkOtherCompetencies"
    End If
    If Selection.Sections.First.Index = 7 Then
    Selection.GoTo What:=wdGoToBookmark, Name:="bkOverall"
    End If
    If Selection.Sections.First.Index = 8 Then
    Selection.GoTo What:=wdGoToBookmark, Name:="bkManagerDate"
    End If
    If Selection.Sections.First.Index = 9 Then
    Selection.GoTo What:=wdGoToBookmark, Name:="bkDepartmental"
    End If
    If Selection.Sections.First.Index = 10 Then
    Selection.GoTo What:=wdGoToBookmark, Name:="bkTitleDate"
    End If

    If ActiveDocument.ProtectionType = wdNoProtection Then
    ActiveDocument.Protect _
    Type:=wdAllowOnlyFormFields, NoReset:=True
    End If

  5. #5
    mallen1
    Guest

    Re: Word Forms (Word 2000)

    I think I'm doing something wrong. Where does the InitialiseTemplate macro reside in the Word form template--in initial user form, a module or This Document? I am new to programming and tried putting your sample code in each container and then running the template, but I keep getting a runtime error and can't tell if the keybindings code will work for the form. Appreciate any advice you can give. Many thanks.

  6. #6
    Silver Lounger Charles Kenyon's Avatar
    Join Date
    Jan 2001
    Location
    Sun Prairie, Wisconsin, Wisconsin, USA
    Posts
    2,049
    Thanks
    124
    Thanked 119 Times in 116 Posts

    Re: Word Forms (Word 2000)

    Rather than the repeated IF statements, you might want to explore the CASE statement.

    I take it that your subs, PrevCell and NextCell are activated by the tab key when you are in a protected form. Interesting.
    Charles Kyle Kenyon
    Madison, Wisconsin

  7. #7
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Word Forms (Word 2000)

    That is a good question - I hadn't testrun geoff's code so hadn't thought about that.

    It looks like the code needs to run from a standard module in a global template.
    It sounds like you have a specific custom template for the form document, which is a good idea, and normally you'd want to have any code located in the template.
    But in this case, the code's got statements like:

    CustomizationContext = ActiveDocument.AttachedTemplate
    KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyTab), _
    KeyCategory:=wdKeyCategoryMacro, Command:="GotoNextSection"
    KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyShift, wdKeyTab), _
    KeyCategory:=wdKeyCategoryMacro, Command:="GotoPrevSection"

    which are there to localize the key customizations to the attached template; however if you run code with a reference to "AttachedTemplate" in a template, you'll get an runtime error.

    A quick and easy way to test this code would be to put it into a code module in your Normal.dot, and test running it from there.
    If you're satisfied that you want to use it, then move it into a proper global template.

    Hope this helps,
    Gary

  8. #8
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Word Forms (Word 2000)

    I would not put this in normal.dot, as it would change the behaviour in all documents.

    I keep it in the template where it is applicable, but I only need to run it once. If I run it a second time, I get an error, because the keybinding has now become attached to the template. I only keep the keybinding code there for reference- and I put a comment on there to say that it is for reference only.
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

  9. #9
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Word Forms (Word 2000)

    Thanks Geoff!

  10. #10
    mallen1
    Guest

    Re: Word Forms (Word 2000)

    Many thanks for the clarification. After commenting out my NextCell and PrevCell code, I ran the procedure once and saved. However, because my form was set up with a table structure (rows, cells), when I tabbed from a row that was unprotected, it just kept adding blank rows--it did not move to the next section, nor did the Shift + Tab move to previous section. The intercepted NextCell and PrevCell work fine in my form; the only scenario where I have trouble is Shift+Tab from first form field in a protected section, to previous unprotected section, which is a table row. I've tried bookmarks, section indexes, etc. I think there must be a built-in combination command of which I am not aware as nothing seems to work. Thanks for your help. If you can think of anything else, I'd really appreciate it. Until next time....

  11. #11
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Word Forms (Word 2000)

    It appears that when you press a tab or shift + tab from a form field, it does its macro handling, and then when it's all finished, it does its processing for the tab or shift + tab, thus overriding any positioning. Sendkeys operate after this positioning takes place- that might do your job.
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

  12. #12
    mallen1
    Guest

    Re: Word Forms (Word 2000)

    I think you are right about the dual processing in scenario of first field in protected section trying to move to previous unprotected section. I did try using SendKeys but it did not work for me either. I finally contacted Microsoft Premier Support, and the MCSD said that Shift+Tab cannot be intercepted in the scenario of first field in a protected section to previous section that is unprotected. However, assigning a macro that will navigate backward in the form from section to section with keystrokes, e.g., CTRL + T)works. So guidelines will be given to the form's users to use tab key to move forward in form; use CTRL + T to move backwards in form. Many thanks to you and the other gentleman who took the time to try and help me out with this problem. This was my first time using Woody's Lounge and I've been quite impressed. I'm sure I'll have another problem soon that needs a solution, and I'll be back here to see your expert guidance. Thanks again...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •