I am really stuck at the moment.. I have been looking this error up on the iternet for ages but cannot see how it fits with what I am doing....
I copied the following code which is supposed to merge PowerPoint files using OpenXML but when running the code I get the following error:
System.Xml.XmlException: The ':' character, hexadecimal value 0x3A, cannot be included in a name.
destSp = destinationPresentationPar
... which is within the 3rd code snippet in point 7 of the article.
Can anyone suggest when I could change this code to make it work?,,, It appears to be an XML error but I don't have control of the XML a its a MS PowerPoint 2010 file its referring to I believe.
Any help would be much much appreciated... I have spent 2 weeks on Open XML and have found it difficult to pick it up! :-(
I have attached the code too.
private void MergePresentationSlides(string sourcePresentation, string destinationPresentation)
int id = 0;
//Open destination presentation
using (PresentationDocument myDestDeck = PresentationDocument.Open(destinationPresentation, true))
PresentationPart destinationPresentationPart = myDestDeck.PresentationPart;
if (destinationPresentationPart.Presentation.SlideIdList == null)
destinationPresentationPart.Presentation.SlideIdList = new SlideIdList();
using (PresentationDocument mySourceDeck = PresentationDocument.Open(sourcePresentation, false))
PresentationPart sourcePresentationPart = mySourceDeck.PresentationPart;
//Get unique IDs for the slides master and slide lists for us later.
uniqueID = GetMaxSlideMasterID(destinationPresentationPart.Presentation.SlideMasterIdList);
uint maxSlideID = GetMaxSlideId(destinationPresentationPart.Presentation.SlideIdList);
//Copy each slide in the source presentaiton and order of the destination presentation
foreach (SlideId slideId in sourcePresentationPart.Presentation.SlideIdList)
// Create a unique relationship Id.
sp = (SlidePart)sourcePresentationPart.GetPartById(slideId.RelationshipId);
relId = sourcePresentation.Remove(sourcePresentation.IndexOf('.')) + id;
//Add the slide part to the destination presentation.
destSp = destinationPresentationPart.AddPart<SlidePart>(sp, relId);
//The master part was added so make sure the relationship is in place
destMasterPart = destSp.SlideLayoutPart.SlideMasterPart;
//Add slide master to slide master list
newsSlideMasterId = new SlideMasterId();
newsSlideMasterId.RelationshipId = destinationPresentationPart.GetIdOfPart(destMasterPart);
newsSlideMasterId.Id = uniqueID;
//Add slide to slide list
newsSlideId = new SlideId();
newsSlideId.RelationshipId = relId;
newsSlideId.Id = maxSlideID;
//Make sure all slide IDs are unique
//Save the changes to the destination deck