Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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:
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 8-Jan-13 23:28pm
Edited 9-Jan-13 1:22am
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Code to set number list in Word with .NET Word API.
            //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;
            }
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 275
1 DamithSL 265
2 CPallini 235
3 Maciej Los 185
4 George Jonsson 170
0 OriginalGriff 5,415
1 DamithSL 4,422
2 Maciej Los 3,820
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,911


Advertise | Privacy | Mobile
Web02 | 2.8.141216.1 | Last Updated 14 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100