Click here to Skip to main content
12,065,204 members (43,765 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# Interop MS-Word
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
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160204.4 | Last Updated 14 Jan 2013
Copyright © CodeProject, 1999-2016
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