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: PublicSub IXMLSpyPlugIn_OnCommand(ByVal nID AsLong, ByVal pXMLSpy AsObject)
If (Not (pXMLSpy IsNothing)) 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
IfNot (objDoc Is Nothing) Then
objDoc.SetPathName objDlg.FileName
objDoc.Save
Set objDoc = Nothing End If End If End If