Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default VBA userform with minimize button

Just started to learn COM add-ins with Office XP and Office XP developer.
One strange, but interesting thing I noted is that I can make a VBA userform
with a minimize and maximize button without using any Windows API.

This is what I have:
A very simple .vba project with the following modules:

a normal VBA userform, only holding a label with caption with the following
code:
----------------------------------------------------------------------------
----------------------

Option Explicit

Private Sub UserForm_Activate()
Me.BackColor = RGB(221, 230, 228)
End Sub


A normal code module with the following code:
--------------------------------------------------------

Option Explicit

Public appHostApp As Application
Public gAddInInst As Object

Public Const PROG_ID_START As String = "!<"
Public Const PROG_ID_END As String = ""

Public MenuEvents As CMenuEvents

A Class module with the following code:
------------------------------------------------

Option Explicit

Private WithEvents btnMenuItem1 As Office.CommandBarButton

Friend Sub CreateMenuItems()

With appHostApp.CommandBars.ActiveMenuBar.Controls("Too ls").Controls
Set btnMenuItem1 = .Add
With btnMenuItem1
.Caption = "Load Form"
.OnAction = PROG_ID_START & gAddInInst.progID & PROG_ID_END
.BeginGroup = True
End With
End With

End Sub

Friend Sub DeleteMenuItems()
On Error Resume Next
btnMenuItem1.Delete
End Sub

Private Sub btnMenuItem1_Click(ByVal Ctrl As Office.CommandBarButton, _
CancelDefault As Boolean)
UserForm1.Show vbModeless
End Sub


A add-in designer module with the following code:
------------------------------------------------------------

Option Explicit

Implements IDTExtensibility2

Private Sub IDTExtensibility2_OnAddInsUpdate(custom() As Variant)

End Sub

Private Sub IDTExtensibility2_OnBeginShutdown(custom() As Variant)

End Sub

Private Sub IDTExtensibility2_OnStartupComplete(custom() As Variant)

End Sub

Private Sub IDTExtensibility2_OnConnection(ByVal Application As Object, _
ByVal ConnectMode As
AddInDesignerObjects.ext_ConnectMode, _
ByVal AddInInst As Object, _
custom() As Variant)
'Store startup reference
Set appHostApp = Application
Set gAddInInst = AddInInst

Set MenuEvents = New CMenuEvents
MenuEvents.CreateMenuItems

End Sub

Private Sub IDTExtensibility2_OnDisconnection(ByVal RemoveMode As
AddInDesignerObjects.ext_DisconnectMode, custom() As Variant)

If RemoveMode = ext_dm_UserClosed Then
MenuEvents.DeleteMenuItems
End If

'remove references to shutdown
Set appHostApp = Nothing

End Sub


That is all.
Now I have no idea why the VBA userform has these extra buttons.
the only line of code I could think of is this one:
.OnAction = PROG_ID_START & gAddInInst.progID & PROG_ID_END

Thanks for any insight in this.


RBS


Nb: Cross-posted to MS.public.Office.developer.com.add_ins










Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Minimize button on userform? Bob Excel Discussion (Misc queries) 3 June 13th 09 11:01 PM
Minimize UserForm Howard31 Excel Discussion (Misc queries) 0 December 17th 08 09:10 PM
Minimize a UserForm SailFL Excel Discussion (Misc queries) 1 August 21st 05 12:45 AM
COM add-in userform minimize button RB Smissaert Excel Programming 2 May 9th 04 01:28 PM
Minimize workwook and then maximize UserForm Fede Querio Excel Programming 0 July 28th 03 06:44 PM


All times are GMT +1. The time now is 03:51 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"