none
C#, word addin, programmary put tabulators to document RRS feed

  • Question

  • Hi,

    I try to create addin to word application.

    How i can put programmary put some tabulators to document?
    Like on the screen: https://dl.dropboxusercontent.com/u/11254269/screen_word.jpg 
    (Tab stop 16cm, Alignment: Right, Leader 3)

    Regards,
    Daro
    • Edited by d4rq000z Tuesday, October 28, 2014 3:22 PM
    Tuesday, October 28, 2014 2:12 PM

Answers

  • Hi,

    The suggestion provied Deric Ferrerira is correct. We can use TabStops collection to add a TabStop object.

    In addtion, to achieve the goal more easily, we can use record macro. And here is a sample based on the requiremnt for your reference:

     Selection.ParagraphFormat.TabStops.Add Position:=InchesToPoints(6.3), _
            Alignment:=wdAlignTabRight, Leader:=wdTabLeaderDashes
    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.

    Thursday, October 30, 2014 7:15 AM
    Moderator
  • Please, check out this http://stackoverflow.com/questions/16590081/adding-a-tab-stop-to-a-paragraph-range-in-c-sharp

     // Open a doc file.
            Application application = new Application();
            Document document = application.Documents.Open(@"C:\Users\mmonkan\Documents\word.docx");
    
            Paragraphs paragraphs = document.Paragraphs;
            Paragraph paragraph = paragraphs[1];
            Range range = paragraph.Range;
            range.SetRange(0, 0);
    
            range.Paragraphs.TabStops.Add(28, WdTabAlignment.wdAlignTabRight);
            range.Paragraphs.TabStops.Add(56, WdTabAlignment.wdAlignTabRight);
    
            // Close word.
            application.Quit(WdSaveOptions.wdSaveChanges);
    

    Could you paste the image here, please? My firewall is blocking dropbox.

    Tuesday, October 28, 2014 2:18 PM

All replies

  • Please, check out this http://stackoverflow.com/questions/16590081/adding-a-tab-stop-to-a-paragraph-range-in-c-sharp

     // Open a doc file.
            Application application = new Application();
            Document document = application.Documents.Open(@"C:\Users\mmonkan\Documents\word.docx");
    
            Paragraphs paragraphs = document.Paragraphs;
            Paragraph paragraph = paragraphs[1];
            Range range = paragraph.Range;
            range.SetRange(0, 0);
    
            range.Paragraphs.TabStops.Add(28, WdTabAlignment.wdAlignTabRight);
            range.Paragraphs.TabStops.Add(56, WdTabAlignment.wdAlignTabRight);
    
            // Close word.
            application.Quit(WdSaveOptions.wdSaveChanges);
    

    Could you paste the image here, please? My firewall is blocking dropbox.

    Tuesday, October 28, 2014 2:18 PM
  • Tuesday, October 28, 2014 3:17 PM
  • Hi,

    The suggestion provied Deric Ferrerira is correct. We can use TabStops collection to add a TabStop object.

    In addtion, to achieve the goal more easily, we can use record macro. And here is a sample based on the requiremnt for your reference:

     Selection.ParagraphFormat.TabStops.Add Position:=InchesToPoints(6.3), _
            Alignment:=wdAlignTabRight, Leader:=wdTabLeaderDashes
    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.

    Thursday, October 30, 2014 7:15 AM
    Moderator
  • Thanks... This piece of code helps me to resolve Tab alignment in Header/Footer.


    Wednesday, July 19, 2017 3:57 AM