Altova XMLSpy 2025 Professional Edition

See also

 

Declaration: OnCommand(nID as long, pXMLSpy as IDispatch)

 

Description

The OnCommand() method of the interface implementation, is called each time a command added by the the IDE plug-in (menu item or toolbar button) is processed. nID stores the command ID defined by the ID element of the respective UIElement.

 

pXMLSpy holds a reference to the dispatch interface of the Application object of XMLSpy.

 

Example

 

Public Sub IXMLSpyPlugIn_OnCommand(ByVal nID As Long, ByVal pXMLSpy As Object)

  If (Not (pXMLSpy Is Nothing)) Then

      Dim objDlg

      Dim objDoc As XMLSpyLib.Document

      Dim objSpy As XMLSpyLib.Application

      Set objSpy = pXMLSpy

       

      If nID = 3 Or nID = 5 Then

          Set objDlg = CreateObject("MSComDlg.CommonDialog")

           objDlg.Filter = "XML Files (*.xml)|*.xml|All Files (*.*)|*.*||"

           objDlg.FilterIndex = 1

           objDlg.ShowOpen

           

          If Len(objDlg.FileName) > 0 Then

              Set objDoc = objSpy.Documents.OpenFile(objDlg.FileName, False)

              Set objDoc = Nothing

          End If

      End If

       

      If nID = 4 Or nID = 6 Then

          Set objDlg = CreateObject("MSComDlg.CommonDialog")

           objDlg.Filter = "All Files (*.*)|*.*||"

           objDlg.Flags = cdlOFNPathMustExist

           objDlg.ShowSave

           

          If Len(objDlg.FileName) > 0 Then

              Set objDoc = objSpy.ActiveDocument

               

              If Not (objDoc Is Nothing) Then

                   objDoc.SetPathName objDlg.FileName

                   objDoc.Save

                  Set objDoc = Nothing

              End If

          End If

      End If

       

      Set objSpy = Nothing

  End If

End Sub

© 2018-2024 Altova GmbH