vba - How to make a option in a macro in word selected by default? -


i have following macro in word 2010. make value 1 (copenhagen) preselected when run macro - put content control drop down list in document copenhagen preselected.

how do ?:

sub cities() ' ' cities macro ' ' selection.range.contentcontrols.add (wdcontentcontroldropdownlist) selection.parentcontentcontrol.title = "cities" selection.parentcontentcontrol.lockcontentcontrol = false selection.parentcontentcontrol.dropdownlistentries.add text:="copenhagen", value:="1" selection.parentcontentcontrol.dropdownlistentries.add text:="new york", value:="2" selection.parentcontentcontrol.dropdownlistentries.add text:="london", value:="3" selection.parentcontentcontrol.dropdownlistentries.add text:="paris", value:="4" selection.moveright unit:=wdcharacter, count:=1 end sub 

thanks in advance!

/ anders h.

did study the documentation? word 2013 more detailed 2010 version of page.

sub cities()     '     ' cities macro     '     '     dim objcc contentcontrol     dim objce contentcontrollistentry      set objcc = selection.range.contentcontrols.add(wdcontentcontroldropdownlist)     objcc         .title = "cities"         .lockcontentcontrol = false         '.dropdownlistentries.add text:="copenhagen", value:="1"         set objce = .dropdownlistentries.add("copenhagen", "1")         objce.select         'or         '.dropdownlistentries.add("copenhagen", "1").select          .dropdownlistentries.add text:="new york", value:="2"         .dropdownlistentries.add text:="london", value:="3"         .dropdownlistentries.add text:="paris", value:="4"     end     'selection.moveright unit:=wdcharacter, count:=1     'selection no longer in document range end sub 

this uses select method select copenhagen. mean, however, selection no longer in document-range. can use like:

activedocument.characters(1).select 

(or million other ways..) move cursor document-range, leaving copenhagen selected.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -