473,396 Members | 1,767 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

User Interface for .NET Add-Ins?

I created an addin using VB.Net. I added a windows form to the addin, but I
can not figure out how to have the form open up in the addin.

Is this possible. I only see a file frmMain.vb in the dev environmnet. I
was surprised not to see a frmMain.frm?

How can I have a form as part of an Add-In?

Thanks in advance.
Jul 21 '05 #1
8 1088
Jim:

can you show me the code you are using
"Jim M" <an********@discussions.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
I created an addin using VB.Net. I added a windows form to the addin, but I can not figure out how to have the form open up in the addin.

Is this possible. I only see a file frmMain.vb in the dev environmnet. I
was surprised not to see a frmMain.frm?

How can I have a form as part of an Add-In?

Thanks in advance.

Jul 21 '05 #2
Jim:

can you show me the code you are using
"Jim M" <an********@discussions.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
I created an addin using VB.Net. I added a windows form to the addin, but I can not figure out how to have the form open up in the addin.

Is this possible. I only see a file frmMain.vb in the dev environmnet. I
was surprised not to see a frmMain.frm?

How can I have a form as part of an Add-In?

Thanks in advance.

Jul 21 '05 #3
Thanks for the help. There is not much code, I can not seem to get past
square one. I guess I just want a form to open as the default user
interface when the button is clicked.

Jim
Private Sub MyButton_Click(ByVal Ctrl As
Microsoft.Office.Core.CommandBarButton, ByRef CancelDefault As Boolean)
Handles MyButton.Click

MsgBox("Our CommandBar button was pressed!")

HERE IS WHERE I WANT TO DISPLAY A FORM. I HAVE A FORM IN MY PROJECT (VISUAL
STUDIO .NET), BUT I DO NOT KNOW HOW TO GET IT TO DISPLAY ON THE BUTTON
CLICK.

I TRIED

frmMain.show vbModal

BUT IT DID NTO WORK.

End Sub
Imports Microsoft.Office.Core

imports Extensibility

imports System.Runtime.InteropServices

#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 MyCommAddinSetup
project

' by right clicking the project in the Solution Explorer, then choosing
install.

#End Region

<GuidAttribute("09C5278D-7B1A-4E15-9F5C-B022E42CE8AF"),
ProgIdAttribute("MyCommAddin.Connect")> _

Public Class Connect

Implements Extensibility.IDTExtensibility2

Dim applicationObject As Object

Dim addInInstance As Object

Dim WithEvents MyButton As CommandBarButton

'(Global Declarations)



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

On Error Resume Next

' Notify the user you are shutting down, and delete the button.

MsgBox("Our custom Add-in is unloading.")

MyButton.Delete()

MyButton = Nothing

End Sub

Public Sub OnAddInsUpdate(ByRef custom As System.Array) Implements Extensibi
lity.IDTExtensibility2.OnAddInsUpdate

End Sub

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

Dim oCommandBars As CommandBars

Dim oStandardBar As CommandBar

On Error Resume Next

' Set up a custom button on the "Standard" command bar.

oCommandBars = applicationObject.CommandBars

If oCommandBars Is Nothing Then

' Outlook has the CommandBars collection on the Explorer object.

oCommandBars = applicationObject.ActiveExplorer.CommandBars

End If

oStandardBar = oCommandBars.Item("Standard")

If oStandardBar Is Nothing Then

' Access names its main toolbar Database.

oStandardBar = oCommandBars.Item("Database")

End If

' In case the button was not deleted, use the exiting one.

MyButton = oStandardBar.Controls.Item("My Custom Button")

If MyButton Is Nothing Then

MyButton = oStandardBar.Controls.Add(1)

With MyButton

..Caption = "My Custom Button"

..Style = MsoButtonStyle.msoButtonCaption

' The following items are optional, but recommended.

' The Tag property lets you quickly find the control

' and helps MSO keep track of it when more than

' one application window is visible. The property is required

' by some Office applications and should be provided.

..Tag = "My Custom Button"

' The OnAction property is optional but recommended.

' It should be set to the ProgID of the add-in, so that if

' the add-in is not loaded when a user clicks the button,

' MSO loads the add-in automatically and then raises

' the Click event for the add-in to handle.

..OnAction = "!<MyCOMAddin.Connect>"

..Visible = True

End With

End If

' Display a simple message to show which application you started in.

MsgBox("Started in " & applicationObject.Name & ".")

oStandardBar = Nothing

oCommandBars = Nothing

'frmLogin.

End Sub

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

On Error Resume Next

If RemoveMode <> Extensibility.ext_DisconnectMode.ext_dm_HostShutdo wn Then _

Call OnBeginShutdown(custom)

applicationObject = Nothing



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

MsgBox("On Connection In MyAddin")

applicationObject = application

addInInstance = addInInst

' If you aren't in startup, manually call OnStartupComplete.

If (connectMode <> Extensibility.ext_ConnectMode.ext_cm_Startup) Then _

Call OnStartupComplete(custom)

End Sub



"William Ryan eMVP" <bi**@NoSp4m.devbuzz.com> wrote in message
news:em*************@TK2MSFTNGP09.phx.gbl...
Jim:

can you show me the code you are using
"Jim M" <an********@discussions.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
I created an addin using VB.Net. I added a windows form to the addin, but
I
can not figure out how to have the form open up in the addin.

Is this possible. I only see a file frmMain.vb in the dev environmnet.

I was surprised not to see a frmMain.frm?

How can I have a form as part of an Add-In?

Thanks in advance.


Jul 21 '05 #4
Jim,

In .NET all windows (forms) are classes, so what you need to do is to
create a variable of the type your window class is and create the object.
Once you have the object you can call the show-method on it.

HTH,

//Andreas

"Jim M" <an********@discussions.microsoft.com> skrev i meddelandet
news:OP**************@tk2msftngp13.phx.gbl...
Thanks for the help. There is not much code, I can not seem to get past
square one. I guess I just want a form to open as the default user
interface when the button is clicked.

Jim
Private Sub MyButton_Click(ByVal Ctrl As
Microsoft.Office.Core.CommandBarButton, ByRef CancelDefault As Boolean)
Handles MyButton.Click

MsgBox("Our CommandBar button was pressed!")

HERE IS WHERE I WANT TO DISPLAY A FORM. I HAVE A FORM IN MY PROJECT (VISUAL STUDIO .NET), BUT I DO NOT KNOW HOW TO GET IT TO DISPLAY ON THE BUTTON
CLICK.

I TRIED

frmMain.show vbModal

BUT IT DID NTO WORK.

End Sub
Imports Microsoft.Office.Core

imports Extensibility

imports System.Runtime.InteropServices

#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 MyCommAddinSetup
project

' by right clicking the project in the Solution Explorer, then choosing
install.

#End Region

<GuidAttribute("09C5278D-7B1A-4E15-9F5C-B022E42CE8AF"),
ProgIdAttribute("MyCommAddin.Connect")> _

Public Class Connect

Implements Extensibility.IDTExtensibility2

Dim applicationObject As Object

Dim addInInstance As Object

Dim WithEvents MyButton As CommandBarButton

'(Global Declarations)



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

On Error Resume Next

' Notify the user you are shutting down, and delete the button.

MsgBox("Our custom Add-in is unloading.")

MyButton.Delete()

MyButton = Nothing

End Sub

Public Sub OnAddInsUpdate(ByRef custom As System.Array) Implements Extensibi lity.IDTExtensibility2.OnAddInsUpdate

End Sub

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

Dim oCommandBars As CommandBars

Dim oStandardBar As CommandBar

On Error Resume Next

' Set up a custom button on the "Standard" command bar.

oCommandBars = applicationObject.CommandBars

If oCommandBars Is Nothing Then

' Outlook has the CommandBars collection on the Explorer object.

oCommandBars = applicationObject.ActiveExplorer.CommandBars

End If

oStandardBar = oCommandBars.Item("Standard")

If oStandardBar Is Nothing Then

' Access names its main toolbar Database.

oStandardBar = oCommandBars.Item("Database")

End If

' In case the button was not deleted, use the exiting one.

MyButton = oStandardBar.Controls.Item("My Custom Button")

If MyButton Is Nothing Then

MyButton = oStandardBar.Controls.Add(1)

With MyButton

.Caption = "My Custom Button"

.Style = MsoButtonStyle.msoButtonCaption

' The following items are optional, but recommended.

' The Tag property lets you quickly find the control

' and helps MSO keep track of it when more than

' one application window is visible. The property is required

' by some Office applications and should be provided.

.Tag = "My Custom Button"

' The OnAction property is optional but recommended.

' It should be set to the ProgID of the add-in, so that if

' the add-in is not loaded when a user clicks the button,

' MSO loads the add-in automatically and then raises

' the Click event for the add-in to handle.

.OnAction = "!<MyCOMAddin.Connect>"

.Visible = True

End With

End If

' Display a simple message to show which application you started in.

MsgBox("Started in " & applicationObject.Name & ".")

oStandardBar = Nothing

oCommandBars = Nothing

'frmLogin.

End Sub

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

On Error Resume Next

If RemoveMode <> Extensibility.ext_DisconnectMode.ext_dm_HostShutdo wn Then _
Call OnBeginShutdown(custom)

applicationObject = Nothing



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

MsgBox("On Connection In MyAddin")

applicationObject = application

addInInstance = addInInst

' If you aren't in startup, manually call OnStartupComplete.

If (connectMode <> Extensibility.ext_ConnectMode.ext_cm_Startup) Then _

Call OnStartupComplete(custom)

End Sub



"William Ryan eMVP" <bi**@NoSp4m.devbuzz.com> wrote in message
news:em*************@TK2MSFTNGP09.phx.gbl...
Jim:

can you show me the code you are using
"Jim M" <an********@discussions.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
I created an addin using VB.Net. I added a windows form to the addin, but
I
can not figure out how to have the form open up in the addin.

Is this possible. I only see a file frmMain.vb in the dev
environmnet. I was surprised not to see a frmMain.frm?

How can I have a form as part of an Add-In?

Thanks in advance.



Jul 21 '05 #5
Thanks for the help. There is not much code, I can not seem to get past
square one. I guess I just want a form to open as the default user
interface when the button is clicked.

Jim
Private Sub MyButton_Click(ByVal Ctrl As
Microsoft.Office.Core.CommandBarButton, ByRef CancelDefault As Boolean)
Handles MyButton.Click

MsgBox("Our CommandBar button was pressed!")

HERE IS WHERE I WANT TO DISPLAY A FORM. I HAVE A FORM IN MY PROJECT (VISUAL
STUDIO .NET), BUT I DO NOT KNOW HOW TO GET IT TO DISPLAY ON THE BUTTON
CLICK.

I TRIED

frmMain.show vbModal

BUT IT DID NTO WORK.

End Sub
Imports Microsoft.Office.Core

imports Extensibility

imports System.Runtime.InteropServices

#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 MyCommAddinSetup
project

' by right clicking the project in the Solution Explorer, then choosing
install.

#End Region

<GuidAttribute("09C5278D-7B1A-4E15-9F5C-B022E42CE8AF"),
ProgIdAttribute("MyCommAddin.Connect")> _

Public Class Connect

Implements Extensibility.IDTExtensibility2

Dim applicationObject As Object

Dim addInInstance As Object

Dim WithEvents MyButton As CommandBarButton

'(Global Declarations)



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

On Error Resume Next

' Notify the user you are shutting down, and delete the button.

MsgBox("Our custom Add-in is unloading.")

MyButton.Delete()

MyButton = Nothing

End Sub

Public Sub OnAddInsUpdate(ByRef custom As System.Array) Implements Extensibi
lity.IDTExtensibility2.OnAddInsUpdate

End Sub

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

Dim oCommandBars As CommandBars

Dim oStandardBar As CommandBar

On Error Resume Next

' Set up a custom button on the "Standard" command bar.

oCommandBars = applicationObject.CommandBars

If oCommandBars Is Nothing Then

' Outlook has the CommandBars collection on the Explorer object.

oCommandBars = applicationObject.ActiveExplorer.CommandBars

End If

oStandardBar = oCommandBars.Item("Standard")

If oStandardBar Is Nothing Then

' Access names its main toolbar Database.

oStandardBar = oCommandBars.Item("Database")

End If

' In case the button was not deleted, use the exiting one.

MyButton = oStandardBar.Controls.Item("My Custom Button")

If MyButton Is Nothing Then

MyButton = oStandardBar.Controls.Add(1)

With MyButton

..Caption = "My Custom Button"

..Style = MsoButtonStyle.msoButtonCaption

' The following items are optional, but recommended.

' The Tag property lets you quickly find the control

' and helps MSO keep track of it when more than

' one application window is visible. The property is required

' by some Office applications and should be provided.

..Tag = "My Custom Button"

' The OnAction property is optional but recommended.

' It should be set to the ProgID of the add-in, so that if

' the add-in is not loaded when a user clicks the button,

' MSO loads the add-in automatically and then raises

' the Click event for the add-in to handle.

..OnAction = "!<MyCOMAddin.Connect>"

..Visible = True

End With

End If

' Display a simple message to show which application you started in.

MsgBox("Started in " & applicationObject.Name & ".")

oStandardBar = Nothing

oCommandBars = Nothing

'frmLogin.

End Sub

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

On Error Resume Next

If RemoveMode <> Extensibility.ext_DisconnectMode.ext_dm_HostShutdo wn Then _

Call OnBeginShutdown(custom)

applicationObject = Nothing



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

MsgBox("On Connection In MyAddin")

applicationObject = application

addInInstance = addInInst

' If you aren't in startup, manually call OnStartupComplete.

If (connectMode <> Extensibility.ext_ConnectMode.ext_cm_Startup) Then _

Call OnStartupComplete(custom)

End Sub



"William Ryan eMVP" <bi**@NoSp4m.devbuzz.com> wrote in message
news:em*************@TK2MSFTNGP09.phx.gbl...
Jim:

can you show me the code you are using
"Jim M" <an********@discussions.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
I created an addin using VB.Net. I added a windows form to the addin, but
I
can not figure out how to have the form open up in the addin.

Is this possible. I only see a file frmMain.vb in the dev environmnet.

I was surprised not to see a frmMain.frm?

How can I have a form as part of an Add-In?

Thanks in advance.


Jul 21 '05 #6
Jim,

In .NET all windows (forms) are classes, so what you need to do is to
create a variable of the type your window class is and create the object.
Once you have the object you can call the show-method on it.

HTH,

//Andreas

"Jim M" <an********@discussions.microsoft.com> skrev i meddelandet
news:OP**************@tk2msftngp13.phx.gbl...
Thanks for the help. There is not much code, I can not seem to get past
square one. I guess I just want a form to open as the default user
interface when the button is clicked.

Jim
Private Sub MyButton_Click(ByVal Ctrl As
Microsoft.Office.Core.CommandBarButton, ByRef CancelDefault As Boolean)
Handles MyButton.Click

MsgBox("Our CommandBar button was pressed!")

HERE IS WHERE I WANT TO DISPLAY A FORM. I HAVE A FORM IN MY PROJECT (VISUAL STUDIO .NET), BUT I DO NOT KNOW HOW TO GET IT TO DISPLAY ON THE BUTTON
CLICK.

I TRIED

frmMain.show vbModal

BUT IT DID NTO WORK.

End Sub
Imports Microsoft.Office.Core

imports Extensibility

imports System.Runtime.InteropServices

#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 MyCommAddinSetup
project

' by right clicking the project in the Solution Explorer, then choosing
install.

#End Region

<GuidAttribute("09C5278D-7B1A-4E15-9F5C-B022E42CE8AF"),
ProgIdAttribute("MyCommAddin.Connect")> _

Public Class Connect

Implements Extensibility.IDTExtensibility2

Dim applicationObject As Object

Dim addInInstance As Object

Dim WithEvents MyButton As CommandBarButton

'(Global Declarations)



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

On Error Resume Next

' Notify the user you are shutting down, and delete the button.

MsgBox("Our custom Add-in is unloading.")

MyButton.Delete()

MyButton = Nothing

End Sub

Public Sub OnAddInsUpdate(ByRef custom As System.Array) Implements Extensibi lity.IDTExtensibility2.OnAddInsUpdate

End Sub

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

Dim oCommandBars As CommandBars

Dim oStandardBar As CommandBar

On Error Resume Next

' Set up a custom button on the "Standard" command bar.

oCommandBars = applicationObject.CommandBars

If oCommandBars Is Nothing Then

' Outlook has the CommandBars collection on the Explorer object.

oCommandBars = applicationObject.ActiveExplorer.CommandBars

End If

oStandardBar = oCommandBars.Item("Standard")

If oStandardBar Is Nothing Then

' Access names its main toolbar Database.

oStandardBar = oCommandBars.Item("Database")

End If

' In case the button was not deleted, use the exiting one.

MyButton = oStandardBar.Controls.Item("My Custom Button")

If MyButton Is Nothing Then

MyButton = oStandardBar.Controls.Add(1)

With MyButton

.Caption = "My Custom Button"

.Style = MsoButtonStyle.msoButtonCaption

' The following items are optional, but recommended.

' The Tag property lets you quickly find the control

' and helps MSO keep track of it when more than

' one application window is visible. The property is required

' by some Office applications and should be provided.

.Tag = "My Custom Button"

' The OnAction property is optional but recommended.

' It should be set to the ProgID of the add-in, so that if

' the add-in is not loaded when a user clicks the button,

' MSO loads the add-in automatically and then raises

' the Click event for the add-in to handle.

.OnAction = "!<MyCOMAddin.Connect>"

.Visible = True

End With

End If

' Display a simple message to show which application you started in.

MsgBox("Started in " & applicationObject.Name & ".")

oStandardBar = Nothing

oCommandBars = Nothing

'frmLogin.

End Sub

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

On Error Resume Next

If RemoveMode <> Extensibility.ext_DisconnectMode.ext_dm_HostShutdo wn Then _
Call OnBeginShutdown(custom)

applicationObject = Nothing



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

MsgBox("On Connection In MyAddin")

applicationObject = application

addInInstance = addInInst

' If you aren't in startup, manually call OnStartupComplete.

If (connectMode <> Extensibility.ext_ConnectMode.ext_cm_Startup) Then _

Call OnStartupComplete(custom)

End Sub



"William Ryan eMVP" <bi**@NoSp4m.devbuzz.com> wrote in message
news:em*************@TK2MSFTNGP09.phx.gbl...
Jim:

can you show me the code you are using
"Jim M" <an********@discussions.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
I created an addin using VB.Net. I added a windows form to the addin, but
I
can not figure out how to have the form open up in the addin.

Is this possible. I only see a file frmMain.vb in the dev
environmnet. I was surprised not to see a frmMain.frm?

How can I have a form as part of an Add-In?

Thanks in advance.



Jul 21 '05 #7
Thanks. I will try it. Any clue to the syntax for creating a variable for
standard window class?

"Andreas Håkansson" <andy.h (at) telia.com> wrote in message
news:Oy**************@TK2MSFTNGP10.phx.gbl...
Jim,

In .NET all windows (forms) are classes, so what you need to do is to
create a variable of the type your window class is and create the object.
Once you have the object you can call the show-method on it.

HTH,

//Andreas

"Jim M" <an********@discussions.microsoft.com> skrev i meddelandet
news:OP**************@tk2msftngp13.phx.gbl...
Thanks for the help. There is not much code, I can not seem to get past
square one. I guess I just want a form to open as the default user
interface when the button is clicked.

Jim
Private Sub MyButton_Click(ByVal Ctrl As
Microsoft.Office.Core.CommandBarButton, ByRef CancelDefault As Boolean)
Handles MyButton.Click

MsgBox("Our CommandBar button was pressed!")

HERE IS WHERE I WANT TO DISPLAY A FORM. I HAVE A FORM IN MY PROJECT (VISUAL
STUDIO .NET), BUT I DO NOT KNOW HOW TO GET IT TO DISPLAY ON THE BUTTON
CLICK.

I TRIED

frmMain.show vbModal

BUT IT DID NTO WORK.

End Sub
Imports Microsoft.Office.Core

imports Extensibility

imports System.Runtime.InteropServices

#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 MyCommAddinSetup project

' by right clicking the project in the Solution Explorer, then choosing
install.

#End Region

<GuidAttribute("09C5278D-7B1A-4E15-9F5C-B022E42CE8AF"),
ProgIdAttribute("MyCommAddin.Connect")> _

Public Class Connect

Implements Extensibility.IDTExtensibility2

Dim applicationObject As Object

Dim addInInstance As Object

Dim WithEvents MyButton As CommandBarButton

'(Global Declarations)



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

On Error Resume Next

' Notify the user you are shutting down, and delete the button.

MsgBox("Our custom Add-in is unloading.")

MyButton.Delete()

MyButton = Nothing

End Sub

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

Extensibi
lity.IDTExtensibility2.OnAddInsUpdate

End Sub

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

Dim oCommandBars As CommandBars

Dim oStandardBar As CommandBar

On Error Resume Next

' Set up a custom button on the "Standard" command bar.

oCommandBars = applicationObject.CommandBars

If oCommandBars Is Nothing Then

' Outlook has the CommandBars collection on the Explorer object.

oCommandBars = applicationObject.ActiveExplorer.CommandBars

End If

oStandardBar = oCommandBars.Item("Standard")

If oStandardBar Is Nothing Then

' Access names its main toolbar Database.

oStandardBar = oCommandBars.Item("Database")

End If

' In case the button was not deleted, use the exiting one.

MyButton = oStandardBar.Controls.Item("My Custom Button")

If MyButton Is Nothing Then

MyButton = oStandardBar.Controls.Add(1)

With MyButton

.Caption = "My Custom Button"

.Style = MsoButtonStyle.msoButtonCaption

' The following items are optional, but recommended.

' The Tag property lets you quickly find the control

' and helps MSO keep track of it when more than

' one application window is visible. The property is required

' by some Office applications and should be provided.

.Tag = "My Custom Button"

' The OnAction property is optional but recommended.

' It should be set to the ProgID of the add-in, so that if

' the add-in is not loaded when a user clicks the button,

' MSO loads the add-in automatically and then raises

' the Click event for the add-in to handle.

.OnAction = "!<MyCOMAddin.Connect>"

.Visible = True

End With

End If

' Display a simple message to show which application you started in.

MsgBox("Started in " & applicationObject.Name & ".")

oStandardBar = Nothing

oCommandBars = Nothing

'frmLogin.

End Sub

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

On Error Resume Next

If RemoveMode <> Extensibility.ext_DisconnectMode.ext_dm_HostShutdo wn Then _

Call OnBeginShutdown(custom)

applicationObject = Nothing



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

MsgBox("On Connection In MyAddin")

applicationObject = application

addInInstance = addInInst

' If you aren't in startup, manually call OnStartupComplete.

If (connectMode <> Extensibility.ext_ConnectMode.ext_cm_Startup) Then _

Call OnStartupComplete(custom)

End Sub



"William Ryan eMVP" <bi**@NoSp4m.devbuzz.com> wrote in message
news:em*************@TK2MSFTNGP09.phx.gbl...
Jim:

can you show me the code you are using
"Jim M" <an********@discussions.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
> I created an addin using VB.Net. I added a windows form to the
addin, but
I
> can not figure out how to have the form open up in the addin.
>
> Is this possible. I only see a file frmMain.vb in the dev

environmnet.
I
> was surprised not to see a frmMain.frm?
>
> How can I have a form as part of an Add-In?
>
> Thanks in advance.
>
>



Jul 21 '05 #8
Thanks. I will try it. Any clue to the syntax for creating a variable for
standard window class?

"Andreas Håkansson" <andy.h (at) telia.com> wrote in message
news:Oy**************@TK2MSFTNGP10.phx.gbl...
Jim,

In .NET all windows (forms) are classes, so what you need to do is to
create a variable of the type your window class is and create the object.
Once you have the object you can call the show-method on it.

HTH,

//Andreas

"Jim M" <an********@discussions.microsoft.com> skrev i meddelandet
news:OP**************@tk2msftngp13.phx.gbl...
Thanks for the help. There is not much code, I can not seem to get past
square one. I guess I just want a form to open as the default user
interface when the button is clicked.

Jim
Private Sub MyButton_Click(ByVal Ctrl As
Microsoft.Office.Core.CommandBarButton, ByRef CancelDefault As Boolean)
Handles MyButton.Click

MsgBox("Our CommandBar button was pressed!")

HERE IS WHERE I WANT TO DISPLAY A FORM. I HAVE A FORM IN MY PROJECT (VISUAL
STUDIO .NET), BUT I DO NOT KNOW HOW TO GET IT TO DISPLAY ON THE BUTTON
CLICK.

I TRIED

frmMain.show vbModal

BUT IT DID NTO WORK.

End Sub
Imports Microsoft.Office.Core

imports Extensibility

imports System.Runtime.InteropServices

#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 MyCommAddinSetup project

' by right clicking the project in the Solution Explorer, then choosing
install.

#End Region

<GuidAttribute("09C5278D-7B1A-4E15-9F5C-B022E42CE8AF"),
ProgIdAttribute("MyCommAddin.Connect")> _

Public Class Connect

Implements Extensibility.IDTExtensibility2

Dim applicationObject As Object

Dim addInInstance As Object

Dim WithEvents MyButton As CommandBarButton

'(Global Declarations)



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

On Error Resume Next

' Notify the user you are shutting down, and delete the button.

MsgBox("Our custom Add-in is unloading.")

MyButton.Delete()

MyButton = Nothing

End Sub

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

Extensibi
lity.IDTExtensibility2.OnAddInsUpdate

End Sub

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

Dim oCommandBars As CommandBars

Dim oStandardBar As CommandBar

On Error Resume Next

' Set up a custom button on the "Standard" command bar.

oCommandBars = applicationObject.CommandBars

If oCommandBars Is Nothing Then

' Outlook has the CommandBars collection on the Explorer object.

oCommandBars = applicationObject.ActiveExplorer.CommandBars

End If

oStandardBar = oCommandBars.Item("Standard")

If oStandardBar Is Nothing Then

' Access names its main toolbar Database.

oStandardBar = oCommandBars.Item("Database")

End If

' In case the button was not deleted, use the exiting one.

MyButton = oStandardBar.Controls.Item("My Custom Button")

If MyButton Is Nothing Then

MyButton = oStandardBar.Controls.Add(1)

With MyButton

.Caption = "My Custom Button"

.Style = MsoButtonStyle.msoButtonCaption

' The following items are optional, but recommended.

' The Tag property lets you quickly find the control

' and helps MSO keep track of it when more than

' one application window is visible. The property is required

' by some Office applications and should be provided.

.Tag = "My Custom Button"

' The OnAction property is optional but recommended.

' It should be set to the ProgID of the add-in, so that if

' the add-in is not loaded when a user clicks the button,

' MSO loads the add-in automatically and then raises

' the Click event for the add-in to handle.

.OnAction = "!<MyCOMAddin.Connect>"

.Visible = True

End With

End If

' Display a simple message to show which application you started in.

MsgBox("Started in " & applicationObject.Name & ".")

oStandardBar = Nothing

oCommandBars = Nothing

'frmLogin.

End Sub

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

On Error Resume Next

If RemoveMode <> Extensibility.ext_DisconnectMode.ext_dm_HostShutdo wn Then _

Call OnBeginShutdown(custom)

applicationObject = Nothing



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

MsgBox("On Connection In MyAddin")

applicationObject = application

addInInstance = addInInst

' If you aren't in startup, manually call OnStartupComplete.

If (connectMode <> Extensibility.ext_ConnectMode.ext_cm_Startup) Then _

Call OnStartupComplete(custom)

End Sub



"William Ryan eMVP" <bi**@NoSp4m.devbuzz.com> wrote in message
news:em*************@TK2MSFTNGP09.phx.gbl...
Jim:

can you show me the code you are using
"Jim M" <an********@discussions.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
> I created an addin using VB.Net. I added a windows form to the
addin, but
I
> can not figure out how to have the form open up in the addin.
>
> Is this possible. I only see a file frmMain.vb in the dev

environmnet.
I
> was surprised not to see a frmMain.frm?
>
> How can I have a form as part of an Add-In?
>
> Thanks in advance.
>
>



Jul 21 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: nsr93 | last post by:
I am not sure if this was the proper group to post this, but here is my question: I am a Java consultant. I have new client I am working for to make a web based application similar to an...
6
by: Earl Teigrob | last post by:
I am writing an application that dynamically loads user controls at run time based on user options. I would like to give my users the ability to build their own user controls and add them to my...
4
by: Earl Teigrob | last post by:
I am writing an application that dynamically loads user controls at run time based on user options. I would like to give my users the ability to build their own user controls and add them to my...
8
by: mark.norgate | last post by:
I've run into a few problems trying to use generics for user controls (classes derived from UserControl). I'm using the Web Application model rather than the Web Site model. The first problem...
6
by: Ronald S. Cook | last post by:
We have a Windows app that has one main form (a shell, sort of). We then load user controls into a panel on the form depending on what the user has selected. Our current code to unload the...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.