Altova XMLSpy 2023 Enterprise Edition

声明

OnCommand(nID as long, pXMLSpy as IDispatch)

 

描述

每次处理IDE插件添加的命令(菜单项或工具栏按钮)时都会调用接口实现的OnCommand()方法。nID存储由相应的UIElementID元素定义的命令ID。pXMLSpy持有对XMLSpy的Application对象的调度接口的引用。

 

示例

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