How to load 2 commandbars from xml files |
Post Reply |
Author | |
xfsriddler
Groupie Joined: 22 February 2010 Location: United States Status: Offline Points: 16 |
Post Options
Thanks(0)
Posted: 24 May 2012 at 3:54pm |
I am having a difficult time finding any documentation on the
procedure for loading a toolbar from a saved xml file. I need to have 2 toolbars on the bottom of my form that are loaded from 2 different xml files. Can you provide a simple example that I can use to do this ?
|
|
SuperMario
Admin Group Joined: 14 February 2004 Status: Offline Points: 18057 |
Post Options
Thanks(0)
|
Public Sub SaveXMLString(fileName As String) Dim FreeF As Integer, sFile As String, sLayout As String Dim XMLLayout As String On Error Resume Next: 'Creates a string containing the CommandBars layout, state, and settings. The state options stored in the myStateOptions 'object specifies which settings should be saved to the string. To allow the XML file to be opened in the Designer Studio, 'the profile name MUST be set to "DesignerFile" XMLLayout = CommandBars.SaveStateToXMLString("DesignerFile", myStateOptions) 'XML string will be saved to a xml file. Note that the file extension is .XML. Opening a file 'of type XML in a web browser will correctly format the XML sting. sFile = fileName FreeF = FreeFile Kill sFile Open sFile For Binary As #FreeF Put #FreeF, , XMLLayout Close #FreeF End Sub Public Sub LoadXMLString(fileName As String) Dim FreeF As Integer, sFile As String, sLayout As String Dim XMLLayout As String On Error Resume Next: 'XML string will be loaded from the file. sFile = fileName FreeF = FreeFile XMLLayout = Space(FileLen(sFile)) Open sFile For Binary As #FreeF Get #FreeF, , XMLLayout Close #FreeF On Error GoTo 0 If (Not bSaveOnlyCustomized And bSerializeControls) Then 'This is needed when the entire toolbar layout is loaded, not just user customization. 'When the layout is loaded, the toolbars not present in the saved layout will not be deleted. 'So you must manually remove all toolbars before loading a layout. 'NOTE: The XML file must have been saved with bSaveOnlyCustomized = False And bSerializeControls = True 'or the layout will not load properly. CommandBars.DeleteAll End If 'Load the "DesignerFile" profile from the myXMLLayout string. The state options stored in the 'myStateOptions object specify how and what to restore of the Command Bars settings. CommandBars.LoadStateFromXMLString "DesignerFile", XMLLayout, myStateOptions End Sub Private Sub xmlFileLoad() Dim sFile As String With dlgCommonDialog .InitDir = App.Path .DialogTitle = "Load XML Layout" .CancelError = False 'ToDo: set the flags and attributes of the common dialog control .Filter = "xml Files (*.xml)|*.xml" .ShowOpen If Len(.fileName) = 0 Then Exit Sub End If sFile = .fileName End With LoadXMLString (sFile) End Sub Private Sub xmlFileSave() Dim sFile As String With dlgCommonDialog .InitDir = App.Path .DialogTitle = "Save XML Layout" .CancelError = False 'ToDo: set the flags and attributes of the common dialog control .Filter = "xml Files (*.xml)|*.xml" .ShowSave If Len(.fileName) = 0 Then Exit Sub End If sFile = .fileName End With SaveXMLString (sFile) End Sub
|
|
xfsriddler
Groupie Joined: 22 February 2010 Location: United States Status: Offline Points: 16 |
Post Options
Thanks(0)
|
thanks, but how would I load 2 different tool bars on the same
form ?
|
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |