Hi there, I hope your appreciated help.
First of all I must say that I am a newbie when it comes to net language.
The platform is C#.
This is my problem.
I need replace the value of DateTime.Now.ToString("dd/mm/yyyy") in all slides of my powerpoint presentation generate in OpenXml.
Now if try my net code the new value of DateTime.Now.ToString("dd/mm/yyyy") is superimposed in the old value of DateTime.Now.ToString("dd/mm/yyyy")
If you have link for similar task, please give it me.
Can you help me? thank you in advance.
Your help would be very appreciated
Thanks for your time and hints.
Loading

Nitesh KejriwalRank #253 · 9.9K reputationPosted Apr 21, 2012, 5:32 PM EDT
Chevy Mark Sunderland159 reputationPosted Apr 22, 2012, 12:23 AM EDT
You have right:
string fileName = @"C:\Inetpub\wwwroot\pptx\ppt1.pptx";
using (PresentationDocument prstDoc = PresentationDocument.Open("ppt1.pptx", true))
{
string newValue = DateTime.Now.ToString("MMMM dd, yyyy");
foreach (SlidePart sPart in prstDoc.PresentationPart.SlideParts)
{
Slide sld = sPart.Slide;
var datePlaceholders = sld.CommonSlideData.ShapeTree.ChildElements.OfType
Where(s => s.NonVisualShapeProperties.NonVisualDrawingProperties.Name.Value == "Date Placeholder 3");
if (datePlaceholders != null)
{
datePlaceholders.ToList().ForEach(datePlaceholder=>
{
datePlaceholder.InsertNewValue(newValue);
});
}
}
prstDoc.PresentationPart.Presentation.Save();
}
Nitesh KejriwalRank #253 · 9.9K reputationPosted Apr 22, 2012, 3:12 AM EDT