Click here to Skip to main content
15,888,113 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all

i have a word document in which i have 2 different type of list.
first is like:
1. USA
2. UK
3. UAE

and second is like :
i. USA
ii. UK
iii. UAE

so by c# how can i get formats of these lists. i have tried so far:
C#
object oMissing = System.Reflection.Missing.Value;
            Word.ApplicationClass oWord = new Word.ApplicationClass();
            oWord.Visible = true;
            Word.Documents oDocs = oWord.Documents;           
            object oFile = txtFileName.Text;
            // If the Microsoft Word 14.0 Object Library is referenced           
            Word._Document oDoc = oDocs.Open(ref oFile, ref oMissing,
                ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                ref oMissing, ref oMissing);
           Word.Range rng = oDoc.Content;          
            //RunMacro(oWord, new Object[] { "Transform_HTML" });           


            MessageBox.Show(oDoc.Lists[0].StyleName.ToString());


But it shows nothing. i need a result like this:

Type=1
or
Type=i

please help
Posted
Updated 9-Jan-13 0:22am
v2

 
Share this answer
 
Code to set number list in Word with .NET Word API.
C#
//Load Document
Document doc = new Document();
doc.LoadFromFile(@"..\..\..\Sample.docx");

//Set Bullet Style
Section s = doc.Sections[0];

for (int i = 1; i< s.Paragraphs.Count; i++)
{
    Paragraph p = s.Paragraphs[i];
    p.ListFormat.ApplyNumberedStyle();
    p.ListFormat.CurrentListLevel.NumberPosition = -12;
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900