Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-11-2014, 03:15 AM
QA_Compliance_Advisor QA_Compliance_Advisor is offline VBA Dropdown change list Entries automatically Windows 7 32bit VBA Dropdown change list Entries automatically Office 2007
Advanced Beginner
VBA Dropdown change list Entries automatically
 
Join Date: Jul 2014
Posts: 44
QA_Compliance_Advisor is on a distinguished road
Default VBA Dropdown change list Entries automatically

I would like to know how i would go about changing a dropdown box in mulitple documents and change the name of the dropdown name.



currently the dropdown is named 'dropdown1' it needs to be changed to 'drpVessel'.

does any one have any suggestion the best way around this?
Reply With Quote
  #2  
Old 09-11-2014, 07:20 PM
macropod's Avatar
macropod macropod is offline VBA Dropdown change list Entries automatically Windows 7 64bit VBA Dropdown change list Entries automatically Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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

What kind of dropdown and, aside from the name change, what other changes?
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 09-11-2014, 11:42 PM
QA_Compliance_Advisor QA_Compliance_Advisor is offline VBA Dropdown change list Entries automatically Windows 7 32bit VBA Dropdown change list Entries automatically Office 2010 32bit
Advanced Beginner
VBA Dropdown change list Entries automatically
 
Join Date: Jul 2014
Posts: 44
QA_Compliance_Advisor is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
What kind of dropdown and, aside from the name change, what other changes?

Content Control dropdown list, the name of the dropdown and the content of the dropdown list.
Reply With Quote
  #4  
Old 09-11-2014, 11:51 PM
macropod's Avatar
macropod macropod is offline VBA Dropdown change list Entries automatically Windows 7 64bit VBA Dropdown change list Entries automatically Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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

So which do you want to change - the tag or the title?
As for the content, what do you want to do - add items, delete items, change their display names or values, something else?
If the changes are substantial it may be simpler to delete the existing controls & replace them with entirely new ones.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 09-12-2014, 12:22 AM
gmayor's Avatar
gmayor gmayor is offline VBA Dropdown change list Entries automatically Windows 7 64bit VBA Dropdown change list Entries automatically Office 2010 32bit
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

One possibility is to use a variation of the following function in conjunction with http://www.gmayor.com/document_batch_processes.htm which will handle the files and folders.
Make whatever changes to 'oCC' that you require and the add-in will do the same for all matching files in the folder.

Code:
Function Dropdown(oDoc As Document) As Boolean
Dim oCC As ContentControl
    On Error GoTo Err_Handler
    For Each oCC In oDoc.ContentControls
        If oCC.Title = "Dropdown1" Then
            With oCC
                .Title = "drpVessel"
                .Tag = .Title
                With .DropdownListEntries
                    .Clear
                    .Add "Item 1"
                    .Add "Item 2"
                    .Add "Item 3"
                    .Add "Item 4"
                End With
            End With
            Exit For
        End If
    Next oCC
    Dropdown = True
lbl_Exit:
    Exit Function
Err_Handler:
    Dropdown = False
    Resume lbl_Exit
End Function
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #6  
Old 09-12-2014, 12:30 AM
QA_Compliance_Advisor QA_Compliance_Advisor is offline VBA Dropdown change list Entries automatically Windows 7 32bit VBA Dropdown change list Entries automatically Office 2010 32bit
Advanced Beginner
VBA Dropdown change list Entries automatically
 
Join Date: Jul 2014
Posts: 44
QA_Compliance_Advisor is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
So which do you want to change - the tag or the title?
As for the content, what do you want to do - add items, delete items, change their display names or values, something else?
If the changes are substantial it may be simpler to delete the existing controls & replace them with entirely new ones.

some of them are from 2003-2007 which have Bookmark so would like to change the bookmark name, if I am correct in thinking that is how content control dropdown work in 2003-2007.
Reply With Quote
  #7  
Old 09-12-2014, 12:43 AM
gmayor's Avatar
gmayor gmayor is offline VBA Dropdown change list Entries automatically Windows 7 64bit VBA Dropdown change list Entries automatically Office 2010 32bit
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

Content controls were launched in Word 2007, and improved in 2010. They are not compatible with 2003. I raised an eyebrow when you mentioned the name Dropdown1 which suggested legacy form fields as by default content control dropdowns do not have titles, and if you were adding one you would surely type something more meaningful.

The code I posted will not of course work with legacy form fields. For that to work we would need more information about whether the form is protected and whether it is protected with a password.

Now also you are talking about 'some' of the documents. A batch process can accommodate different document types, but it will perform the same task on each.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #8  
Old 09-12-2014, 12:51 AM
QA_Compliance_Advisor QA_Compliance_Advisor is offline VBA Dropdown change list Entries automatically Windows 7 32bit VBA Dropdown change list Entries automatically Office 2010 32bit
Advanced Beginner
VBA Dropdown change list Entries automatically
 
Join Date: Jul 2014
Posts: 44
QA_Compliance_Advisor is on a distinguished road
Default

Quote:
Originally Posted by gmayor View Post
Content controls were launched in Word 2007, and improved in 2010. They are not compatible with 2003. I raised an eyebrow when you mentioned the name Dropdown1 which suggested legacy form fields as by default content control dropdowns do not have titles, and if you were adding one you would surely type something more meaningful.

The code I posted will not of course work with legacy form fields. For that to work we would need more information about whether the form is protected and whether it is protected with a password.

Now also you are talking about 'some' of the documents. A batch process can accommodate different document types, but it will perform the same task on each.
The documents are not Password protected. Unfortunately those responsible for inserting the dropdowns are not aware of how to porgam and didn't understand the significance of the naming of things.

I have docs made in 2003, 2007 and 2010. What info do you need.

furthermore have have programmed to convert all 2003-2007 docs to be 2010 can that help?

Last edited by QA_Compliance_Advisor; 09-12-2014 at 12:52 AM. Reason: more info
Reply With Quote
  #9  
Old 09-12-2014, 01:01 AM
gmayor's Avatar
gmayor gmayor is offline VBA Dropdown change list Entries automatically Windows 7 64bit VBA Dropdown change list Entries automatically Office 2010 32bit
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

Can you attach a sample document so we can see what we are dealing with?
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #10  
Old 09-12-2014, 01:09 AM
QA_Compliance_Advisor QA_Compliance_Advisor is offline VBA Dropdown change list Entries automatically Windows 7 32bit VBA Dropdown change list Entries automatically Office 2010 32bit
Advanced Beginner
VBA Dropdown change list Entries automatically
 
Join Date: Jul 2014
Posts: 44
QA_Compliance_Advisor is on a distinguished road
Default

Quote:
Originally Posted by gmayor View Post
Can you attach a sample document so we can see what we are dealing with?

here is a sample
Attached Files
File Type: doc 700-02-5 Handover Record Crew Change - RAO Rev 2.doc (42.5 KB, 13 views)
Reply With Quote
  #11  
Old 09-12-2014, 02:20 AM
gmayor's Avatar
gmayor gmayor is offline VBA Dropdown change list Entries automatically Windows 7 64bit VBA Dropdown change list Entries automatically Office 2010 32bit
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

OK, it is confirmed a form field and the document is unprotected, so the following will handle that. You can re-activate the commented out list section to change the vessel names.

This also revealed a minor bug in my batch process when run in Word 2010 that has now been fixed in version 2.3.

Code:
Function Ddown(oDoc As Document) As Boolean
Dim oFF As FormField
    On Error GoTo Err_Handler
    For Each oFF In oDoc.FormFields
        If oFF.name = "Dropdown1" Then
            With oFF
                .name = "drpVessel"
                'With .Dropdown.ListEntries
                '    .Clear
                '    .Add "Item 1"
                '    .Add "Item 2"
                '    .Add "Item 3"
                '    .Add "Item 4"
                'End With
            End With
            Exit For
        End If
    Next oFF
    Ddown = True
lbl_Exit:
    Exit Function
Err_Handler:
    Ddown = False
    Resume lbl_Exit
End Function
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #12  
Old 09-12-2014, 04:29 AM
QA_Compliance_Advisor QA_Compliance_Advisor is offline VBA Dropdown change list Entries automatically Windows 7 32bit VBA Dropdown change list Entries automatically Office 2010 32bit
Advanced Beginner
VBA Dropdown change list Entries automatically
 
Join Date: Jul 2014
Posts: 44
QA_Compliance_Advisor is on a distinguished road
Default

Quote:
Originally Posted by gmayor View Post
OK, it is confirmed a form field and the document is unprotected, so the following will handle that. You can re-activate the commented out list section to change the vessel names.

This also revealed a minor bug in my batch process when run in Word 2010 that has now been fixed in version 2.3.

Code:
Function Ddown(oDoc As Document) As Boolean
Dim oFF As FormField
    On Error GoTo Err_Handler
    For Each oFF In oDoc.FormFields
        If oFF.name = "Dropdown1" Then
            With oFF
                .name = "drpVessel"
                'With .Dropdown.ListEntries
                '    .Clear
                '    .Add "Item 1"
                '    .Add "Item 2"
                '    .Add "Item 3"
                '    .Add "Item 4"
                'End With
            End With
            Exit For
        End If
    Next oFF
    Ddown = True
lbl_Exit:
    Exit Function
Err_Handler:
    Ddown = False
    Resume lbl_Exit
End Function

Could being a bit dense, how do i incorporate this into having this automate process for every document in subfolders?
Reply With Quote
  #13  
Old 09-12-2014, 05:04 AM
gmayor's Avatar
gmayor gmayor is offline VBA Dropdown change list Entries automatically Windows 7 64bit VBA Dropdown change list Entries automatically Office 2010 32bit
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

You will need the add-in which handles the folders and sub folders - http://www.gmayor.com/document_batch_processes.htm
which I referred to in my first post. Run the above code as a custom process.
The instructions are on the web page.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #14  
Old 09-12-2014, 06:17 AM
QA_Compliance_Advisor QA_Compliance_Advisor is offline VBA Dropdown change list Entries automatically Windows 7 32bit VBA Dropdown change list Entries automatically Office 2010 32bit
Advanced Beginner
VBA Dropdown change list Entries automatically
 
Join Date: Jul 2014
Posts: 44
QA_Compliance_Advisor is on a distinguished road
Default

Quote:
Originally Posted by gmayor View Post
You will need the add-in which handles the folders and sub folders - http://www.gmayor.com/document_batch_processes.htm
which I referred to in my first post. Run the above code as a custom process.
The instructions are on the web page.

gmayor, thank you clearly being dense.
Reply With Quote
  #15  
Old 09-16-2014, 03:06 AM
QA_Compliance_Advisor QA_Compliance_Advisor is offline VBA Dropdown change list Entries automatically Windows 7 32bit VBA Dropdown change list Entries automatically Office 2010 32bit
Advanced Beginner
VBA Dropdown change list Entries automatically
 
Join Date: Jul 2014
Posts: 44
QA_Compliance_Advisor is on a distinguished road
Default

Quote:
Originally Posted by gmayor View Post
OK, it is confirmed a form field and the document is unprotected, so the following will handle that. You can re-activate the commented out list section to change the vessel names.

This also revealed a minor bug in my batch process when run in Word 2010 that has now been fixed in version 2.3.

Code:
Function Ddown(oDoc As Document) As Boolean
Dim oFF As FormField
    On Error GoTo Err_Handler
    For Each oFF In oDoc.FormFields
        If oFF.name = "Dropdown1" Then
            With oFF
                .name = "drpVessel"
                'With .Dropdown.ListEntries
                '    .Clear
                '    .Add "Item 1"
                '    .Add "Item 2"
                '    .Add "Item 3"
                '    .Add "Item 4"
                'End With
            End With
            Exit For
        End If
    Next oFF
    Ddown = True
lbl_Exit:
    Exit Function
Err_Handler:
    Ddown = False
    Resume lbl_Exit
End Function
I have found that there is a more problamatic issue, not all dropdown that I want to change are named dropdown1, but there is a logic all the drop down in the list entry has "select Vessel". what logic would I need to have;

If dropdown list entry = "Select Vessel" then

carry out the change (obviously it probably aint that simple)
Reply With Quote
Reply

Tags
automatically, dropdown, replace

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA Dropdown change list Entries automatically Multiple entries in dropdown lists paul_pearson Word VBA 151 10-18-2023 04:23 PM
Duplicating entries on multiple tabs automatically jbexley Excel 0 08-28-2014 04:48 PM
VBA Dropdown change list Entries automatically Captions automatically updating all previous entries jhats Word 1 07-29-2014 11:53 PM
Dropdown list, Macro shield5 Excel Programming 7 10-27-2013 01:51 AM
Change cell color everytime a value is selected in dropdown list angelica_gloria Excel 4 01-27-2012 06:47 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:16 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