Altova XMLSpy 2024 Enterprise Edition

Deklaration

OnCommand(nID als long, pXMLSpy als IDispatch)

 

Beschreibung

Die OnCommand() Methode der Schnittstellenimplementierung wird jedes Mal aufgerufen, wenn ein zum IDE Plug-In hinzugefügter Befehl (Menübefehl oder Symbolleisten-Schaltfläche) verarbeitet wird. nID speichert die durch das ID-Element des entsprechenden UIElement definierte Befehls-ID. pXMLSpy enthält eine Referenz auf das Dispatch Interface des Application-Objekts von XMLSpy.

 

Beispiel

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

 

© 2017-2023 Altova GmbH