0
votes

(Update: self-answered, below)

Using VS2013 Premium, asp.net. vb.net, website, win7
Using the OpenXML SDK and the OpenXML Productivity Tool

I have a dictionary of class objects which describe graphic shapes (rectangles, arrows, text boxes) by position and text content. I use the class objects to create shapes in a blank PowerPoint presentation. The shapes show up in the correct positions with the correct text. However, I can't figure out how to change some of the styling, starting with the textbox outline style "solid & dark" or "none".

Overall mechanics:

  • started with a PowerPoint 2013 document with one slide with one shape
  • used the Productivity Tool to reflect the PPTX to C#, converted that to VB.Net, put it in a class in my project (again, website)
  • located the place in the code where the shape was added to the slide shape tree
  • replaced that code with a function call to a class that imports the dictionary, translates the dictionary's class objects into openxml shapes, and adds the shapes to the shape tree.

That all works fine.

However, some of the shapes are graphic rectangles which need outlines, and others are text boxes that don't. Again, I can't figure out how to modify the outlines on the textboxes.

This is a test setup which illustrates the problem (although as an openxml newb, I could be missing some very large obvious piece).

Starting point: create a PPTX with a textbox without an outline; copy it; in the PPTX copy add an outline to the textbox, take a look in PowerPoint, and see the comparison below: Comparison of two input powerpoints slides, one with shape with outline, one with shape without outline
Compare the two documents in the OpenXML Productivity Tool, looking at the difference in the XML, and reflect the corresponding code:

Comparison of XML and reflected code of change Open the PPTX with the textbox without the outline in the Productivity Tool, and reflect the full code required to generate that entire PPTX. Put that code in a class in a new website project. Create a webform that will execute that code on page load.

Locate where the textbox is added to the shapetree, and where the shapeproperties are created for the shape. Add the differential code that is supposed to add the outline to the textbox, so that the outline is added to the shapeproperties:

Snapshot showing the differential code added to the Generated code above

Run it with the code active and inactive (using the If statement) and take a look at the resulting PPTX's:

PPTX with textbox without the outline:

Generated PPTX without outline on textbox

PPTX with textbox with the outline (notice: no shape at all)

Generated PPTX with outline on textbox

Then open and compare the new output PPTX's in the Productivity Tool:
("without outline" on the left, "with outline" on the right)

Comparison of new outputs

The comparative XML of the output documents looks the same as it did in the comparison of the starting input documents, however, the output PPT that should have the shape with outline shows nothing. Strangely, the XML shows that the shape is in that PPTX, but it does not show in the PowerPoint client.

Any help with understanding how to add the outline to some of the textboxes, arrows and rectangles and not others would be appreciated.

1

1 Answers

0
votes

The answer came from a different angle. Another element of the ShapeProperties object is the PresetGeometry , which has a ShapeTypeValue

Dim presetGeometry1 As A.PresetGeometry = Nothing
presetGeometry1 = New A.PresetGeometry() With { _
                        .Preset = A.ShapeTypeValues.Rectangle} 
shapeProperties1.Append(presetGeometry1)

While experimenting, I discovered that textboxes do not require ANY preset geometry.

I rewrote the code to not add the PresetGeometry for the textboxes, then set the applicable theme style to have a "dark, solid" outline instead of "no outline". The rectangles appear with outlines according to the theme, and the textboxes appear where they should, without outlines.