⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 connect.dsr

📁 VB automaticlly grap error event
💻 DSR
字号:
VERSION 5.00
Begin {AC0714F6-3D04-11D1-AE7D-00A0C90F26F4} Connect 
   ClientHeight    =   8775
   ClientLeft      =   1875
   ClientTop       =   135
   ClientWidth     =   6585
   _ExtentX        =   11615
   _ExtentY        =   15478
   _Version        =   393216
   Description     =   "Automatic adding of error handling code with ever project you make"
   DisplayName     =   "AutoErrorHandler"
   AppName         =   "Visual Basic"
   AppVer          =   "Visual Basic 6.0"
   LoadName        =   "Startup"
   LoadBehavior    =   1
   RegLocation     =   "HKEY_CURRENT_USER\Software\Microsoft\Visual Basic\6.0"
   CmdLineSupport  =   -1  'True
End
Attribute VB_Name = "Connect"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit

Public MYVBProject              As VBProject
Dim mcbMenuCommandBar         As Office.CommandBarControl
Dim mcbStandardCommandBar     As Office.CommandBarControl
Public WithEvents MenuHandler As CommandBarEvents   'command bar event handler
Attribute MenuHandler.VB_VarHelpID = -1
Public WithEvents ToolBarHandler As CommandBarEvents
Attribute ToolBarHandler.VB_VarHelpID = -1

Private Sub AddinInstance_OnBeginShutdown(custom() As Variant)
    'kill the Class so that it will save the error code to the file.
    'I have put this here because this is called before the project is unloaded
    'So the save rutine can save the rigth DIR
    
    Set ErrorHandle = Nothing
End Sub

'------------------------------------------------------
'this method adds the Add-In to VB
'------------------------------------------------------
Private Sub AddinInstance_OnConnection(ByVal Application As Object, ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, ByVal AddInInst As Object, custom() As Variant)
    'save the vb instance
    Set VBInstance = Application

    If ConnectMode = ext_cm_External Then
        'Used by the wizard toolbar to start this wizard
        frmSetup.Show
    Else
        Set mcbMenuCommandBar = AddToToolsCommandBar("Auto Error Handler")
        Set mcbStandardCommandBar = AddToStandardCommandBar("Auto Error Handler")
        
        'sink the event
        Set Me.MenuHandler = VBInstance.Events.CommandBarEvents(mcbMenuCommandBar)
        Set Me.ToolBarHandler = VBInstance.Events.CommandBarEvents(mcbStandardCommandBar)
    End If
  
    Exit Sub
End Sub

'------------------------------------------------------
'this method removes the Add-In from VB
'------------------------------------------------------
Private Sub AddinInstance_OnDisconnection(ByVal RemoveMode As AddInDesignerObjects.ext_DisconnectMode, custom() As Variant)
On Error Resume Next
    
    'delete the command bar entry
    mcbMenuCommandBar.Delete
    mcbStandardCommandBar.Delete
    
    Unload frmSetup
End Sub

Private Sub IDTExtensibility_OnStartupComplete(custom() As Variant)
    ErrorHandle.GetErrorCode
End Sub

'this event fires when the menu is clicked in the IDE
Private Sub MenuHandler_Click(ByVal CommandBarControl As Object, handled As Boolean, CancelDefault As Boolean)
    frmSetup.Show vbModal
End Sub

Function AddToToolsCommandBar(sCaption As String) As Office.CommandBarControl
Dim cbMenuCommandBar As Office.CommandBarControl  'command bar object
Dim cbMenu As Object
    
    'see if we can find the Tools menu
    Set cbMenu = VBInstance.CommandBars("Tools")
    If cbMenu Is Nothing Then
        'not available so we fail
        Exit Function
    End If
        
    'add it to the command bar
    Set cbMenuCommandBar = VBInstance.CommandBars(1).Controls("Tools").CommandBar.Controls.Add(1, , , 3)

    'set the caption
    cbMenuCommandBar.Caption = sCaption
    
    Set AddToToolsCommandBar = cbMenuCommandBar

End Function

Function AddToStandardCommandBar(sCaption As String) As Office.CommandBarControl
Dim cbMenuCommandBar As Office.CommandBarControl  'command bar object
Dim cbMenu As Object
Dim cbCount As Integer
Dim vClipBoard As Variant

    'see if we can find the Add-Ins menu
    Set cbMenu = VBInstance.CommandBars("Standard")
    If cbMenu Is Nothing Then
        'not available so we fail
        Exit Function
    End If
        
    'add it to the command bar
    cbCount = VBInstance.CommandBars("Standard").Controls.Count
    
    Set cbMenuCommandBar = VBInstance.CommandBars("Standard").Controls.Add(1, , , cbCount)
    
    Clipboard.SetData LoadResPicture("PIC", 0)
    ' Copy the icon from the clipboard to the menu
    ' command's icon.
    cbMenuCommandBar.PasteFace
    
    'set the caption
    cbMenuCommandBar.Caption = sCaption
    cbMenuCommandBar.ToolTipText = "Add Error handling to you code"
    
    Set AddToStandardCommandBar = cbMenuCommandBar

End Function

Private Sub ToolBarHandler_Click(ByVal CommandBarControl As Object, handled As Boolean, CancelDefault As Boolean)
    ErrorHandle.InsertCode
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -