SaveToXML: String;
The SaveToXML method saves the ribbon structure in the XML format and returns the received XML string.
Executing the example requires a form, the Button1 button on this form, and the Ribbon component named Ribbon1. There is a document with the RibbonXML identifier in the repository.
Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
MB: IMetabase;
MObj: IMetabaseObject;
Doc: IDocument;
MStream: IMemoryStream;
TxtWriter: ITextWriter;
Begin
MB := MetabaseClass.Active;
MObj := MB.ItemById("RibbonXML").Edit;
Doc := MObj As IDocument;
MStream := New MemoryStream.Create;
TxtWriter := New TextWriter.Create(MStream);
TxtWriter.Encoding := CodePage.UTF8;
TxtWriter.WriteString(Ribbon1.SaveToXML);
TxtWriter.Flush;
Doc.LoadFromStream(MStream);
Dispose MStream;
MObj.Save;
End Sub Button1OnClick;
Clicking the button saves the ribbon structure to the specified document.
See also: