Hi Cindy,
Here is the macro I recorded. I need the equivalent C# code for this
action.
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 3/28/2005 by Shankar Kumar
'
Selection.FormFields.Add Range:=Selection.Range,
Type:=wdFieldFormDropDown
Selection.PreviousField.Select
With Selection.FormFields(1)
.Name = "Dropdown1"
.EntryMacro = ""
.ExitMacro = ""
.Enabled = True
.OwnHelp = False
.HelpText = ""
.OwnStatus = False
.StatusText = ""
End With
Selection.FormFields("Dropdown1").DropDown.ListEntries.Clear
Selection.FormFields("Dropdown1").DropDown.ListEntries.Add Name:="Item
1"
Selection.FormFields("Dropdown1").DropDown.ListEntries.Add Name:="Item
2"
Selection.FormFields("Dropdown1").DropDown.ListEntries.Add Name:="Item
3"
End Sub
Thx, Shankar
> Hi Shankar,
>
[quoted text clipped - 14 lines]
> This reply is posted in the Newsgroup; please post any follow question or
> reply in the newsgroup and not by e-mail :-)
Cindy M -WordMVP- - 30 Mar 2005 11:07 GMT
Hi Shankar,
> Here is the macro I recorded. I need the equivalent C# code for this
> action.
{
wd.Document doc = wdApp.ActiveDocument;
//ensuring we insert the field at the end of the document
wd.Range rng = doc.Content;
rng.Collapse(ref objCollapseEnd);
wd.FormField ffld = doc.FormFields.Add(rng,
wd.WdFieldType.wdFieldFormDropDown);
ffld.DropDown.ListEntries.Clear();
object objIndex1 = (object) 1;
ffld.DropDown.ListEntries.Add("Three", ref objIndex1);
ffld.DropDown.ListEntries.Add("Two", ref objIndex1);
ffld.DropDown.ListEntries.Add("One", ref objIndex1);
}
Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org
This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :-)