Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Closed Thread
 
Thread Tools Display Modes
  #1  
Old 05-02-2019, 02:44 PM
RaudelJr RaudelJr is offline Odd behavior when Command Buttons are present. Windows 10 Odd behavior when Command Buttons are present. Office 2013
Novice
Odd behavior when Command Buttons are present.
 
Join Date: Apr 2017
Posts: 9
RaudelJr is on a distinguished road
Default Odd behavior when Command Buttons are present.

Hi,



I have a situation where word has an odd behavior when Command Buttons are present.

I'm attaching two Word Template files, one with buttons and one without.

The file with No Buttons was the original file.
I added the buttons to the file to copy content between bookmarks, using a Button and also to reset form by clearing all fields using a Button.

But it seems like adding the Buttons caused a sort of a glitch.

If you look at the VBA code, the UpdateUptions() Macro is supposed to select the corresponding bookmarked dropdowns and display the selections.

It does it correctly when the form has no Buttons. But as soon as the Buttons are added, at the end of the UpdateOptions() macro, Word seems to move to a field that is after the intended dropdown.

The file attached with No Buttons, has the UpdateOptions() macro working as expected, though if you were to edit this file and add a command button, and do nothing more, it will begin having the problem.


And the file attached With Buttons, has the UpdateOptions() macro affected by the presence of the buttons.

Not sure how to resolve the weird behavior.

Thanks in advance for your help.

Raudel

EDIT >> I would like to add, that the issue is easier to observe if you change the Word settings to view Hidden Text (Options>Display>Select Hidden Text
Attached Files
File Type: dotm DropdownDependentNoButtons.dotm (35.9 KB, 8 views)
File Type: dotm DropdownDependentWithButtons.dotm (42.1 KB, 7 views)

Last edited by RaudelJr; 05-02-2019 at 05:02 PM.
  #2  
Old 05-02-2019, 09:39 PM
macropod's Avatar
macropod macropod is online now Odd behavior when Command Buttons are present. Windows 7 64bit Odd behavior when Command Buttons are present. Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Cross-posted at: http://www.vbaexpress.com/forum/show...ns-are-present
For cross-posting etiquette, please read: http://www.excelguru.ca/content.php?184
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
  #3  
Old 05-02-2019, 09:58 PM
RaudelJr RaudelJr is offline Odd behavior when Command Buttons are present. Windows 10 Odd behavior when Command Buttons are present. Office 2019
Novice
Odd behavior when Command Buttons are present.
 
Join Date: Apr 2017
Posts: 9
RaudelJr is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
Sorry about that.

I did post here first, then later in the vbaexpress forum.
I mentioned my cross posting in the first line of my post there, though the site didn't let me post URL strings.

I didn't want to cross post. But I have this document due tomorrow, and I've spend hours researching.

I might end up having to do a workaround.

Any help is appreciated.

Thanks in advance macropod
  #4  
Old 05-03-2019, 12:42 AM
RaudelJr RaudelJr is offline Odd behavior when Command Buttons are present. Windows 10 Odd behavior when Command Buttons are present. Office 2019
Novice
Odd behavior when Command Buttons are present.
 
Join Date: Apr 2017
Posts: 9
RaudelJr is on a distinguished road
Default

I have created a step by step as suggested by Cindy Meister at https://stackoverflow.com/questions/...65262#55965262

I hope you are successful at creating a Macro enabled document that has a working Macro first, but then stops working with the insertion of a Button. Instructions below.

--------------------
Open a Word Document

Create a and enter the following code:

Code:
    Sub UpdateOptions()
    Dim bProtected As Boolean
    'Unprotect the file
    If ActiveDocument.ProtectionType <> wdNoProtection Then
        bProtected = True
        ActiveDocument.Unprotect Password:=""
    End If

    Select Case ActiveDocument.FormFields("Bookmark0").Result
        Case "Bookmark1"
            ActiveDocument.Bookmarks("Bookmark1").Select
            SendKeys "%{down}"  'Displays choices in drop-down field
        Case "Bookmark2"
            ActiveDocument.Bookmarks("Bookmark2").Select
            SendKeys "%{down}"  'Displays choices in drop-down field
        Case "Bookmark3"
            ActiveDocument.Bookmarks("Bookmark3").Select
            SendKeys "%{down}"  'Displays choices in drop-down field
    End Select
    If bProtected = True Then
        ActiveDocument.Protect _
            Type:=wdAllowOnlyFormFields, _
            NoReset:=True, _
            Password:=""
    End If
End Sub
-----------------
On Word Document


Type Bookmark0
Insert a Legacy Drop down Form Field
List: Bookmark1, Bookmark2, Bookmark3
Bookmark: Bookmark0
Run Macro on Exit: UpdateOptions

Enter
Enter
Type Bookmark1
Insert a second Legacy Drop down Form Field
List: 1, 2, 3.
Bookmark: Bookmark1

Enter
Enter
Type Bookmark 2
Insert a third Legacy Drop down Form Field
List: 1, 2, 3.
Bookmark: Bookmark2

Enter
Enter
Type Bookmark3
Insert a fourth Legacy Drop down Form Field
List: 1, 2, 3.
Bookmark: Bookmark3

Your document should look like this at this point:

Bookmark0[dropdown]

Bookmark1[dropdown]

Bookmark2[dropdown]

Bookmark3[dropdown]

Save document as a Macro Enabled document.

Lock document



Testing:
- Change the first drowpdown options only from the available listed options (Bookmark1, Bookmark2, Bookmark3)
- Everytime you change your selection you will be directed to the corresponding Bookmark Dropdown Form Field.
- Should be working as expected.

Next, Button conflict

Unlock document
Insert a Button at the end of the document below Bookmark3
[Button]

Your document should look like the same as above but with a button now:

Bookmark0[dropdown]

Bookmark1[dropdown]

Bookmark2[dropdown]

Bookmark3[dropdown]

[Button]

Lock document



Testing Button conflict:
- Change Bookmak0 selection from (Bookmark1, Bookmark2, Bookmark3)
- Everytime you change your selection you will NOT be directed to the corresponding Bookmark Dropdown Form Field.
- Everytime you change your selection you will be directed to a field after the intended corresponding Bookmark Dropdown Form Field.
- Macro is not working as expected with the presence of a Button.
- Unlock document, delete the button, lock document, it will be working fine again.




Please let me know if you have any questions.

Thank you for any help in advance.

Raudel
  #5  
Old 05-03-2019, 02:46 AM
gmayor's Avatar
gmayor gmayor is offline Odd behavior when Command Buttons are present. Windows 10 Odd behavior when Command Buttons are present. Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Frankly I wouldn't do this with form fields. Content controls make more sense and are faster to process. The coding required is a little different and the buttons shouldn't make a difference (see attached.)

As the document is a template, create new documents from it. I think the attached shows what you want according to the value of one of the drop downs, but it should be easy enough to change.
Attached Files
File Type: dotm DropdownDependentWithButtons.dotm (53.1 KB, 11 views)
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
  #6  
Old 05-03-2019, 05:09 AM
macropod's Avatar
macropod macropod is online now Odd behavior when Command Buttons are present. Windows 7 64bit Odd behavior when Command Buttons are present. Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Now also cross-posted at: https://www.eileenslounge.com/viewto...p?f=26&t=32411
Given your complete disregard for the cross-posting etiquette to which your attention has been drawn, it's evident you really don't care how many peoples' time you waste on this. Thread closed.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Closed Thread

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hiding Command Buttons before PDF ksigcajun Word VBA 3 05-07-2014 05:31 AM
Odd behavior when Command Buttons are present. Command buttons on slidemaster chcope PowerPoint 2 06-13-2013 04:30 PM
Command Buttons lorenambrose Word 0 10-06-2011 11:55 AM
command buttons ronf Excel 0 04-28-2006 08:32 AM
command buttons ronf Excel 0 12-03-2005 06:26 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:57 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft