none
how to create word document file like tree view formate (SEE THE IMAGE) using c# .net RRS feed

Answers

  • Hi Sumit.Pareek,

    Based on the description, it seems that you want to format the text in a document as a tree.

    If I understood correctly, we can use type tab or space to control the format of text. Here is an sample wiring in VBA for your reference:

      Selection.TypeText Text:="Root Folder"
        Selection.TypeParagraph
        Selection.TypeText Text:=vbTab & "Child Folder1"
        Selection.TypeParagraph
        Selection.TypeText Text:=vbTab & "Child Folder2"
        Selection.TypeParagraph
        Selection.TypeText Text:=vbTab & "Child Folder3"
        Selection.TypeParagraph
        Selection.TypeText Text:="Root Folder2"
        Selection.TypeParagraph

    Also you may interested in using list to control the text format in Word document. Here is an sample using VBA for your reference:

      Selection.Range.ListFormat.ApplyListTemplateWithLevel ListTemplate:= _
            ListGalleries(wdOutlineNumberGallery).ListTemplates(1), _
            ContinuePreviousList:=False, ApplyTo:=wdListApplyToWholeList, _
            DefaultListBehavior:=wdWord10ListBehavior
        Selection.TypeText Text:="Root Folder"
        Selection.TypeParagraph
        Selection.TypeText Text:="Child Folder1"
        Selection.HomeKey Unit:=wdLine, Extend:=wdExtend
        Selection.Range.SetListLevel Level:=2
        Selection.EndKey Unit:=wdLine, Extend:=wdExtend
         Selection.TypeParagraph
           Selection.TypeText Text:="Child Folder2"
            Selection.TypeParagraph
           Selection.TypeText Text:="Child Folder3"
            Selection.TypeParagraph
           Selection.TypeText Text:="Root Folder2"
            Selection.HomeKey Unit:=wdLine, Extend:=wdExtend
             Selection.Range.SetListLevel Level:=1

    Screenshot:

    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.

    Monday, November 24, 2014 8:12 AM
    Moderator

All replies

  • Hello,

    VSTO doesn't provide anything for that. I'd suggest asking Word-specific questions on the Word for Developers forum.

    Friday, November 21, 2014 2:12 PM
  • Helllo Eugene astafiev ,

                                            I am not asking for word document only . i am asking that how to create that kind of document in MS word by using c#.

    Friday, November 21, 2014 2:20 PM
  • VSTO is for developing Office add-ins. Do you need to develop an add-in?

    The Word for Developers forum is the right place for such questions.

    Friday, November 21, 2014 2:29 PM
  • Hi Sumit.Pareek,

    Based on the description, it seems that you want to format the text in a document as a tree.

    If I understood correctly, we can use type tab or space to control the format of text. Here is an sample wiring in VBA for your reference:

      Selection.TypeText Text:="Root Folder"
        Selection.TypeParagraph
        Selection.TypeText Text:=vbTab & "Child Folder1"
        Selection.TypeParagraph
        Selection.TypeText Text:=vbTab & "Child Folder2"
        Selection.TypeParagraph
        Selection.TypeText Text:=vbTab & "Child Folder3"
        Selection.TypeParagraph
        Selection.TypeText Text:="Root Folder2"
        Selection.TypeParagraph

    Also you may interested in using list to control the text format in Word document. Here is an sample using VBA for your reference:

      Selection.Range.ListFormat.ApplyListTemplateWithLevel ListTemplate:= _
            ListGalleries(wdOutlineNumberGallery).ListTemplates(1), _
            ContinuePreviousList:=False, ApplyTo:=wdListApplyToWholeList, _
            DefaultListBehavior:=wdWord10ListBehavior
        Selection.TypeText Text:="Root Folder"
        Selection.TypeParagraph
        Selection.TypeText Text:="Child Folder1"
        Selection.HomeKey Unit:=wdLine, Extend:=wdExtend
        Selection.Range.SetListLevel Level:=2
        Selection.EndKey Unit:=wdLine, Extend:=wdExtend
         Selection.TypeParagraph
           Selection.TypeText Text:="Child Folder2"
            Selection.TypeParagraph
           Selection.TypeText Text:="Child Folder3"
            Selection.TypeParagraph
           Selection.TypeText Text:="Root Folder2"
            Selection.HomeKey Unit:=wdLine, Extend:=wdExtend
             Selection.Range.SetListLevel Level:=1

    Screenshot:

    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.

    Monday, November 24, 2014 8:12 AM
    Moderator