none
How to change the Table Border to Squared 'SysDot' Line Style in PowerPoint? RRS feed

  • Question

  • Hi All,

    I am unable to change the Table Border (LineFormat) to 'Squared' 'SysDot' LineStyle for PowerPoint.

    With the below code, it is only making the border as 'Rounded' 'SysDot' line style.

    But by default in PowerPoint, all the listed Border Line Styles (under 'Table Design' menu) are made of Square. But when it is done programmatically, it comes with Rounded Dots.

    I 'Googled' it enough, couldn't find any related answer

    PowerPoint.Table table = shape.Table;
    Cell cell = table.Cell(1, 1);
    LineFormat lineFormat = cell.Borders._Index(1);
    lineFormat.DashStyle = Office.MsoLineDashStyle.msoLineSysDot;

    Expected Border Style

    Actual Border Style from the above code

    Thank you for the help in advance,


    Nat


    • Edited by natsraj Thursday, July 9, 2015 3:41 PM
    Thursday, July 9, 2015 3:41 PM

All replies

  • Hi,

    Did you mean this style?

    square border

    Achived using this syntax

    lineFormat.DashStyle = Office.MsoLineDashStyle.msoLineSquareDot;

    Taken from this article

    * Tested on Office 2013


    Assaf


    • Edited by Assaf L Thursday, July 9, 2015 10:43 PM
    Thursday, July 9, 2015 10:41 PM
  • Hi,

    Thanks for the reply.

    No, that is not what I am looking for. I have pointed out in the below snapshot

    It would be great if someone helps me in this.

    Thanks in Advance,


    Nat

    Friday, July 10, 2015 5:34 AM
  • Hi,

    I played a bit more and now I understand what is your intention

    It actually worked for me

    I used this code sample to achieve what you described:

    Presentation cc = Globals.ThisAddIn.Application.ActivePresentation;
    var dd = cc.Slides[1];
    var shape = dd.Shapes.AddTable(2, 2);
    Table table = shape.Table;
    Cell cell = table.Cell(1, 1);
    Microsoft.Office.Interop.PowerPoint.LineFormat lineFormat = cell.Borders._Index(1);
    Office.MsoLineDashStyle style = MsoLineDashStyle.msoLineDashDot;
    lineFormat.DashStyle = style;
    lineFormat.Weight = 5;
    lineFormat.ForeColor.RGB = 128;

    and the result is:

    Are you simply executing the code you have attached or there is more logic that might affect the final result?

    maybe some style definition on the actual slide that overcomes your intention?

    What version of office are you using?


    Assaf

    Friday, July 10, 2015 7:08 AM
  • Hi,

    Thanks for the attention.

    The code that you have shared, applies a 'Dash Dotted' line type. Please refer the below snapshot

    The code I have shared in the initial question is just a snippet from my application. In the entire application, I am applying Line Style for Table at only one place. I made sure that other part of the application code doesn't affect this piece.

    Moreover I debugged the Line Style Enum of Border value for the desired line style (manually), I got the value of msoLineSysDot. Then i used this in the code to get the desired output. But instead of squared dots, it applied Rounded Dots.

    Also I am testing my code on a empty presentation without any styles applied on that. 

    I am using the version of PowerPoint 2010.

    Thanks in Advance!


    Nat


    • Edited by natsraj Friday, July 10, 2015 9:59 AM
    Friday, July 10, 2015 9:58 AM
  • Hi,

    From my search it seems like you are looking for some control of the "Cap Type" property which has some control of the shape at the border

    I couldn't find any reference to such property in the object reference and the only solution to succesfully control this ability comes from VBA, not C#

    Bottom line, I don't think this ability is supported currently, 

    It would be great if you could share any other findings along your way

    Several links I found with this information:

    MS Word Format Data Series Line Cap Type

    You cannot use VBA code to configure the Cap Type and Join Type properties in Excel


    Good luck!


    Assaf

    Saturday, July 11, 2015 11:17 PM
  • Thank you very much really!!

    As you and I found that Cap type is the only solution to this problem, but left without any options to configure by Microsoft!

    Always there is a limitation waiting for you, when we work with Microsoft products.

    Feeling pretty bad.


    Nat


    • Edited by natsraj Sunday, July 12, 2015 7:01 AM
    Sunday, July 12, 2015 7:01 AM
  • Hi,
    I'm sorry for your feelings here, I think that situations such as that can bring the best of our abilities...

    I thought of something that might work for you, I tested it and think it should do the trick
    Office provides us with the ability to define custom table styles through open office api (reference details here)
    See this link for more details

    I created 2 custom table styles which manipulate table top borders with round and square cap types and saved them inside a presentation template (applying the style to the rest of the borders is simple)
    Than at runtime using VSTO I could create a table and apply the custom styles to it (more details here), hence controlling the cap type at run time

    This is the xml to fill inside the file ppt/tableStyles.xml of the template you should create

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <a:tblStyleLst xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" def="{5C22544A-7EE6-4342-B048-85BDC9FD1C3A}">
    <a:tblStyle styleId="{90651C3A-4460-11DB-9652-00E08161165F}" styleName="Empty Custom Style" >
    <a:wholeTbl>
    <a:tcStyle>
    <a:tcBdr>
    <a:top>
    <a:ln w="50000" cap="rnd" cmpd="sng">
    <a:solidFill>
    <a:srgbClr val="FF0000"/>
    </a:solidFill>
    <a:prstDash val="sysDot" />
    </a:ln>
    </a:top>
    </a:tcBdr>
    </a:tcStyle>
    </a:wholeTbl>
    </a:tblStyle>
    <a:tblStyle styleId="{2A048678-AD1C-4944-BFEE-3CAFDF5B4B64}" styleName="Empty Custom Style 22" >
    <a:wholeTbl>
    <a:tcStyle>
    <a:tcBdr>
    <a:top>
    <a:ln w="50000" cap="sq" cmpd="sng">
    <a:solidFill>
    <a:srgbClr val="FF0000"/>
    </a:solidFill>
    <a:prstDash val="sysDot" />
    </a:ln>
    </a:top>
    </a:tcBdr>
    </a:tcStyle>
    </a:wholeTbl>
    </a:tblStyle>
    </a:tblStyleLst>

    Hope this process answers your need


    Assaf

    Monday, July 13, 2015 8:00 PM