Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it L'avatar di Igor70
    Registrato dal
    Aug 2002
    Messaggi
    131

    [Outlook Add-in] CommandBarButton_Click

    Sto impazzendo
    qualcuno sa dirmi cosa manca a questo codice per funzionare prima che mi pigli un esaurimento

    Imports Microsoft.Office.Core
    imports Extensibility
    imports System.Runtime.InteropServices
    Imports Microsoft.Office.Interop
    Imports Microsoft.VisualBasic.Compatibility

    <GuidAttribute("741F301D-34B6-4E25-B4D4-D74895048B46"), ProgIdAttribute("MyAddin1.Connect")> _
    Public Class Connect

    Implements Extensibility.IDTExtensibility2

    Dim applicationObject as Object
    dim addInInstance as object

    Friend WithEvents CommandBar As CommandBars
    Friend WithEvents CommandBarButton1 As CommandBarButton

    Public Sub OnBeginShutdown(ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnBeginShutdown
    End Sub

    Public Sub OnAddInsUpdate(ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnAddInsUpdate
    End Sub

    Public Sub OnStartupComplete(ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnStartupComplete
    Dim oCommandBar As CommandBar
    Dim oCommandBarPopup As CommandBarPopup
    Dim oCommandBarButton1 As CommandBarButton
    Dim myPicture As stdole.IPictureDisp

    oCommandBar = applicationObject.ActiveExplorer.CommandBars.Add(" Newsletter Command Bar", MsoBarPosition.msoBarTop, False, True)
    oCommandBar.Visible = True
    'oCommandBar = oApp.ActiveExplorer.CommandBars("Standard")
    oCommandBarPopup = oCommandBar.Controls.Add(MsoControlType.msoControl Popup, 1, "", 1, True)
    oCommandBarPopup.Visible = True
    oCommandBarPopup.Caption = "Newsletter"
    oCommandBarButton1 = oCommandBarPopup.Controls.Add(MsoControlType.msoCo ntrolButton, 1, "", 1, True)
    oCommandBarButton1.Visible = True
    oCommandBarButton1.Caption = "New..."

    myPicture = VB6.Support.ImageToIPictureDisp(System.Drawing.Ima ge.FromFile("C:\Documents and Settings\odev\Documenti\Visual Studio Projects\OutlookTest\MyAddin1\NEW.BMP"))
    oCommandBarButton1.Style = MsoButtonStyle.msoButtonIconAndCaption
    oCommandBarButton1.Picture = myPicture

    CommandBarButton1 = oCommandBarButton1
    End Sub

    Public Sub OnDisconnection(ByVal RemoveMode As Extensibility.ext_DisconnectMode, ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnDisconnection
    End Sub

    Public Sub OnConnection(ByVal application As Object, ByVal connectMode As Extensibility.ext_ConnectMode, ByVal addInInst As Object, ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnConnection
    applicationObject = CType(application, Outlook.Application)
    addInInstance = addInInst
    End Sub
    Private Sub oCommandBar_OnUpdate()
    MsgBox("oCommandBar_OnUpdate")
    End Sub
    Private Sub CommandBarButton1_Click(ByVal Ctrl As CommandBarButton, ByVal CancelDefault As Boolean)
    MsgBox("CommandBarButton1_Click")
    End Sub
    End Class

  2. #2
    Utente di HTML.it L'avatar di Igor70
    Registrato dal
    Aug 2002
    Messaggi
    131


    A chi potesse interessare posto la soluzione, con un breve messaggio indirizzato a quel maledetto BASTARDGates:
    Ma a chi caccio le fai scrivere le documentazioni, a tua nonna, dovresi pagarmeto tu questo week-end, PARASSITA!!!


    Scusate, ma vi sembra possibile che per una cazzata del genere uno debba impazzire solo perche una documentazione è scritta alla cacchio...


    Imports Microsoft.Office.Core
    Imports Extensibility
    Imports System.Runtime.InteropServices
    Imports Microsoft.Office.Interop
    Imports Microsoft.VisualBasic.Compatibility

    #Region " Read me for Add-in installation and setup information. "
    ' When run, the Add-in wizard prepared the registry for the Add-in.
    ' At a later time, if the Add-in becomes unavailable for reasons such as:
    ' 1) You moved this project to a computer other than which is was originally created on.
    ' 2) You chose 'Yes' when presented with a message asking if you wish to remove the Add-in.
    ' 3) Registry corruption.
    ' you will need to re-register the Add-in by building the MyAddin1Setup project
    ' by right clicking the project in the Solution Explorer, then choosing install.
    #End Region

    <GuidAttribute("741F301D-34B6-4E25-B4D4-D74895048B46"), ProgIdAttribute("MyAddin1.Connect")> _
    Public Class Connect

    Implements Extensibility.IDTExtensibility2

    Dim applicationObject As Outlook.Application
    Dim addInInstance As Object

    Private MainMenuBar As CommandBar
    Private MenuBarItem As CommandBarControl
    Private WithEvents MenuItem As CommandBarButton


    Public Sub OnBeginShutdown(ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnBeginShutdown

    End Sub

    Public Sub OnAddInsUpdate(ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnAddInsUpdate
    End Sub

    Public Sub OnStartupComplete(ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnStartupComplete
    Try
    InitMenuBarItems("&Travel Tools")
    Catch ex As System.Exception
    MsgBox(ex.Message)
    End Try
    Me.MenuItem = Me.CreateButton(DirectCast(Me.MenuBarItem, CommandBarPopup), "&Create Expense Report")
    End Sub

    Public Sub OnDisconnection(ByVal RemoveMode As Extensibility.ext_DisconnectMode, ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnDisconnection
    End Sub

    Public Sub OnConnection(ByVal application As Object, ByVal connectMode As Extensibility.ext_ConnectMode, ByVal addInInst As Object, ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnConnection
    applicationObject = CType(application, Outlook.Application)
    addInInstance = CType(addInInst, COMAddIn)
    End Sub

    Private Sub InitMenuBarItems(ByVal Caption As String)
    Try
    For Each oObj As CommandBar In applicationObject.ActiveExplorer.CommandBars
    If oObj.Name = "NewsletterBar" Then
    oObj.Delete()
    End If
    Next
    Me.MainMenuBar = applicationObject.ActiveExplorer.CommandBars.Add(" NewsletterBar")
    Me.MainMenuBar.Visible = True

    Me.MenuBarItem = Me.MainMenuBar.Controls.Add(MsoControlType.msoCont rolPopup, Temporary:=True)

    Dim oCommandBarControl As CommandBarControl
    oCommandBarControl = DirectCast(Me.MenuBarItem, CommandBarControl)
    oCommandBarControl.Caption = Caption
    oCommandBarControl.Visible = True
    Catch ex As Exception
    MsgBox(ex.Message, ex.Source)
    End Try
    End Sub
    Private Function CreateButton(ByVal Parent As CommandBarPopup, ByVal Caption As String) As CommandBarButton
    Dim oCommandBarControl As CommandBarButton
    Dim myPicture As stdole.IPictureDisp

    myPicture = VB6.Support.ImageToIPictureDisp(System.Drawing.Ima ge.FromFile("C:\Documents and Settings\odev\Documenti\Visual Studio Projects\OutlookTest\MyAddin1\NEW.BMP"))
    Try
    oCommandBarControl = Parent.Controls.Add(MsoControlType.msoControlButto n, 1, "", 1, True)
    oCommandBarControl.Caption = Caption
    oCommandBarControl.Visible = True
    oCommandBarControl.Style = MsoButtonStyle.msoButtonIconAndCaption
    oCommandBarControl.Picture = myPicture
    Catch ex As Exception
    MsgBox(ex.Message, ex.Source)
    End Try
    Return oCommandBarControl
    End Function

    Private Sub MenuItem_Click(ByVal Ctrl As Microsoft.Office.Core.CommandBarButton, ByRef CancelDefault As Boolean) Handles MenuItem.Click
    Dim frm As New frmNewsletter
    frm.Show()
    End Sub

    End Class

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.