Reading a multilevel list from MS Word Doc and converting it into an HTML nested list using C#

I can achieve the above for a single level list as follows:
foreach (Paragraph item in app.Selection.Range.ListParagraphs)
item.Range.InsertBefore("<li>");
item.Range.InsertAfter("</li>");
Using C#, how can I programmatically convert a multilevel list (like the following) in a Word doc to a nested HTML list? Note: The bullet icons are not important. Thanks..Nam
List from Word Doc:
A
B
C
D
E
F
G
H
I

Hi Nam,
>>how can we programmatically determine the start and end elements of the sub-list with elements C,DE,F,G in the example of my original post? <<
We can check the begin and end elements of the sub-list by the
ListLevelNumber. For example, the sub-list's ListLevelNumber start at 2 by default. Here is the code to find the begin element for your reference:
Sub FindBeginSubElement()
For i = 1 To Selection.Range.ListParagraphs.Count
If Selection.Range.ListParagraphs(i).Range.ListFormat.ListLevelNumber = 2 Then
Debug.Print "begin sub element:" & Selection.Range.ListParagraphs(i).Range.Text
Exit Sub
End If
Next i
End Sub
Also we can loop the selection in reverse order to find the end element for the sub-list.
Hope it is helpful.
Regards & Fei
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.

Similar Messages

  • Creating a pdf from a word doc and the image and footer will not show

    I am trying to create a pdf from a word doc that has an image and footer. Neither will show in the pdf. Also getting this message "Adobe Acrobat Updater has not been able to check for updates recently. Check online to see if solutions are available from the Adobe website." My Cloud says it is updated.

    What was the Original?
    If it was from Word, chances are the top and bottom Margins were set too narrow. (should not be less than .5 inches even more safety 1" would be better). As for graphics. Check in Word preferences (may be called different in a windows machine) make sure in view and Print settings "Graphics" is checked (show Graphics and Print Graphics).

  • Why is does my apple run SLOW.you go to open a program and the circle thing just spins for a delayed period of time.  You change from typing in a word doc and go to say email or internet and it takes several minutes to allow you open anything up.  Like it

    Why is does my apple run SLOW.you go to open a program and the circle thing just spins for a delayed period of time.  You change from typing in a word doc and go to say email or internet and it takes several minutes to allow you open anything up.  Like it is frozen.  I have tried rebooting the computer and it works for a few minutes then gets stuck.

    Which model iMac do you have?
    How large is your HD and how much space do you have left?
    Check out the following & do the necessary: 
    User Tip:  Why is my computer slow?
    What to do when your computer is too slow
    Speeding up your Mac
    OS X (10.6.6)
    Use Software Update or the OS 10.6.8 combo update to update your OS.  Also, update everything SU has to offer for your computer.  When done, repair permissions and restart your computer.

  • I created a pdf form from a Word doc with 9 pt aerial font formatting; the text on the pdf form is aerial 9 pt, but the fields are formatted in courier 12 pt - How do I reformat the font in the fields??

    I created a pdf form from a Word doc with 9 pt aerial font formatting; the text on the pdf form is aerial 9 pt, but the fields are formatted in courier 12 pt - How do I reformat the font in the fields??

    You can set up a temporary button (or link, bookmark, etc.) and add the following JavaScript action:
    // Mouse Up script for a temporary button (or bookmark, etc.)
    // Change the font and font size for all text fields in this document
    for (var i = 0; i < numFields; i += 1) {
        var f = getField(getNthFieldName(i));
        if (f.type === "text") {
            f.textFont = font.Helv;
            f.textSize = 9;
    It also sets the font size, but you can remove that line if you don't need to do that.

  • How to switch from a word doc to another using a keyboard shortcut?

    how to switch from a word doc to another using a keyboard shortcut?

    Cmd+tilde to switch between open Word documents, or
    Cmd+tab to switch between open applications, if that's what you are after?

  • Why can't I edit the Word doc I converted from a PDF?

    Why can't I edit the Word doc I converted from a PDF?
    Help! That is why I bought this software!

    Hi linda007,
    If you can't edit the file once it's converted to Word, it could be that the PDF was created from a scanned page, and then image text wasn't converted to searchable text. ExportPDF should perform Optical Character Recognition by default, but it can be disabled in Reader. Do you know whether OCR was disabled when you converted the page? If it wasn't, make sure that the correct language was selected for OCR. This option appears at the bottom of the ExportPDF panel in Reader, and in the Document Language (for Text Recognition) pop-up menu that appears after you select your file to convert in the ExportPDF online service.
    If everything seems to have been set correctly, and you still can edit the text, please try triple-clicking to select the text in Word. Did that do the trick?
    Best,
    Sara

  • Importing a table from a word doc

    I have several tables I'd like ti include in the ibook i'm creating. If I use the "create page from word document" function I can easily upload everything else from the word doc, but if the table is long then more than half the data is off the page and there is no way to make it continue on the next page. Is there an easier way to make these tables readable? I've tried using the interactive image widget but it's not ideal..
    thank you!!!!

    It seems n imperfect process regardless, sorry.
    I've found there are basically two ways, the first being to rework the data into a compatible table manually on the iBA side, the second being to rework the table on the WORD side so that it is better accepted.
    The specific recipe frequently depends on your data and your skills, I think.

  • Can Form Fields from uploaded WORD docs become Sharepoint columns ?

    Hello -
    We are in the process of uploading many Word docs from Shared drives to Sharepoint (2010 )
    Some of the Word documents have information stored in Form Fields. For Example : BuyerName & SellerName. These fields need to be used in SP for sorting, filtering etc.
    We have tried creating columns on Sharepoint with the same names (BuyerName & SellerName) but the information from the Word docs does not display in the corresponding Sharepoint columns once the docs are uploaded.
    Any advice on how to accomplish this would be greatly appreciated !

    Check if this helps you
    http://office.microsoft.com/en-in/sharepoint-help/use-external-data-columns-in-a-word-document-HA102847511.aspx
    http://www.ilikesharepoint.de/2013/07/sharepoint-connecting-metadata-in-office-documents-to-sharepoint-library-columns/
    http://solidspace.ie/index.php/how-to-insert-sharepoint-metadata-into-your-word-document-using-quick-parts-and-content-types/

  • Reading ams word doc and creating another ms word doc with this same data

    I have a ms word doc and i hav to create different word docs from it with different name.The docs will contain the same data as the mother document but some cases,some strings will be replaced by some new strings for each document to be created.plz help me out.
    File ReadDocFileInput = new File(inFilePath + "APX-DBEST.DOC");
    BufferedReader readXML = new BufferedReader(new InputStreamReader(new FileInputStream(outFile)));
              String FirstTag = null;
              String writeIntoDoc = null;
              String writeTagName = null;
              String writeTagSTEPName = null;
              File WriteDocFileOutput = new File(inFilePath + "APX-DBEST-" + writeTagName + ".RTF");
              BufferedReader fis = new BufferedReader(new InputStreamReader(
                        new FileInputStream(ReadDocFileInput)));
              //FileInputStream fis = new FileInputStream(ReadDocFileInput);
              //FileOutputStream fos = new FileOutputStream(WriteDocFileOutput);
              PrintWriter fos = new PrintWriter(new FileOutputStream(WriteDocFileOutput) );
              //int i =0;
              //char ch;
              while((writeIntoDoc = fis.readLine())!=null){
                   //ch = (char)i;
                   fos.write(writeIntoDoc);
              fis.close();
              fos.close();
              //WriteDocFileOutput.renameTo(new File(inFilePath + "APX-DBEST-" + writeTagName + ".DOC"));
    this is the code i hav written...anything wrong in it?...it does not working.

    I didn't read your code. But if you want to copy a file, commons has a neat tool for it:
    import org.apache.commons.io.IOUtils;
    import java.io.*;
    class CommonsFileCopy {
        public static void main(String[] args) {
            String fIn = "CommonsFileCopy.java";
            String fOut = "(copy) CommonsFileCopy.java";
            try {
                InputStream inStream = new BufferedInputStream(new FileInputStream(fIn));
                OutputStream outStream = new FileOutputStream(new File(fOut));
                IOUtils.copy(inStream, outStream);
                System.out.println("Copied \""+fIn+"\" to \""+fOut+"\" successful");
            catch(IOException ioe) { ioe.printStackTrace(); }
    }

  • Created a pdf from a word-file and inserted formfields. The fields works in other pdf-readers(nitro,reader etc), but not in adobe reader and acrobat. Please help.

    Hi,
    I have created a pdf from a word-file and inserted formfields for a work related file. I've used nitro pro to create the formfield. They works in nitro, reader, foxit etc. but not adobe reader. From page 3 and out, the font wont show when writing in a formfield. Some formfield doesnt even show.
    Please help me fix this (hopefully before the presentation at work friday) :-)
    File in question: Dropbox - Byggeplassperm_bico_prosjektledelse_2.pdf
    Kind regards
    Tobias

    Agreed. Adobe makes no claims that their Reader will work properly with forms made from third party software.

  • Font changes when i try to create a pdf from a word doc

    I am trying to create a pdf from a word doc. I have tried multiple times and each time i do the font i used in the word doc gets changed on the pdf

    This seems to be a common problem... this is not the first time I have seen this. Unless it is a general system font, such as Arial, then it seems not to convert too well.
    So, if it doesn't matter what font, then just change the font.
    Hopefully, Adobe fixes this in the next year. xD
    Good luck
    -Alex

  • How can I transfer text and format from a Word Doc to a new Pages Doc?

    How can I transfer text and format from a Word Doc to a new Pages Doc?

    Select, and Copy in the Word doc and Paste in the Pages doc. It may not be perfect. Importing (Opening) the Word doc is probably better than using Copy/Paste for large amounts of content.
    Jerry

  • I have word docs and power points in Arabic which I should like to read on my Mac. Can anyone offer a view as to how I can do this.?

    I have much training material previously prepared on my former Microsoft pc. Some of the word docs and power points are in arabic on a memory stick now. However my Mac cannot read the arabic at all. Has anyone hd this problem and found a solution?

    Trainer7 wrote:
    my Mac cannot read the arabic at all. ?
    Do you see disconnected Arabic or nonsense?  If nonsense, it could be an encoding problem.  Use the camera icon here to  post screenshot of what you are seeing.
    It is important to understand that MS Word for Mac has never supported connected Arabic.  You have to use some other app, like TextEdit or LibreOffice, and sometimes select the text and change the font to one of those provided by Apple, like Geeza Pro.

  • When I convert a PDF to a Word doc, it "converts" as a picture and I cannot edit the document. What can I do to get the PDF to convert properly?

    When I convert a PDF to a Word doc, it "converts" as a picture and I cannot edit the document. What can I do to get the PDF to convert properly?

    Hi conversionnewbie,
    Are you able to select the text in Word by triple-clicking inside the text box? (Sometimes text selections can be tricky in converted files.) If you can't select the text, then I'm guessing that the PDF was created from a scanned file (so the text becomes images). Make sure that OCR is enabled when you convert the file to Word. OCR is enabled by default in the ExportPDF web interface, but can be disabled in Adobe Reader. If you're converting to Word from within Adobe Reader, make sure that OCR is enabled and that the correct language is selected:
    Please let us know that works for you!
    Best,
    Sara

  • I am looking for an application that would allow me to open a word doc, and take notes in the .doc using a stylus pen.  I'd then like to convert those notes to text, and then be able to copy / paste those notes into an email.  Does this app exist?

    I am looking for an application that would allow me to open a word doc, and take notes in the .doc using a stylus pen.  I'd then like to convert those notes to text, and then be able to copy / paste those notes into an email.  Does this app exist?  It seems like we were doing these same types of things with Palm Pilots years ago, one would think this would work with iPads?

    I don't believe it will open a Word document, but Writepad allows for handwritten conversion of notes to text and then to email. Might help you some of the way...

Maybe you are looking for