Re: AutoNew and Private

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Two entirely separate issues.

"Private" means that the declaration is visible only within the module.

Your 'select case' construction is a simple syntax error: you're missing the
'end select'; and in this case (as in most select case constructions) you
also need to deal with the possibility that the case will be other than
green.







"Dan Kelly" <DanKelly@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:394A3C83-69D3-4F55-A05C-6CFAF30DEB6D@xxxxxxxxxxxxxxxx
I am trying to get my head around Private declarations and AutoNew/AutoOpen
options.

I have the following code that works:

Option Explicit
Dim cb As CommandBarComboBox

Sub AutoNew()
SetComboBox
End Sub

Private Sub SetComboBox
Set cb = CommandBars("Test").Controls.Add(msoControlComboBox)
with cb
.OnAction = "SetColour"
.AddItem "Green"
' Other setup stuff that works....
End With
End Sub

Private Sub SetColour
Select Case cb.Text
Case "Green"
'Run another Macro that doesn't matter here
EndSub

If however I declare AutoNew as Private so that it is hidden from the
Macro
list then the above breaks at the Select Case Statement.

Where am I going wrong?



.



Relevant Pages

  • Re: An event raise twice when click the button.
    ... Private Sub AddinInstance_OnAddInsUpdateAs Variant) ... Private Sub AddinInstance_OnBeginShutdownAs Variant) ... Private WithEvents m_objInsp As Outlook.Inspector ... Dim tempMailItem As Outlook.MailItem ...
    (microsoft.public.office.developer.outlook.vba)
  • Re: An event raise twice when click the button.
    ... Private Sub AddinInstance_OnAddInsUpdateAs Variant) ... Private Sub AddinInstance_OnBeginShutdownAs Variant) ... Private WithEvents m_objInsp As Outlook.Inspector ... Dim tempMailItem As Outlook.MailItem ...
    (microsoft.public.office.developer.outlook.vba)
  • Re: reading mouse wheel rotation in VB6
    ... Private Sub ucSubclass1_MouseWheel ... Private Type tSubData 'Subclass data type ... Private Sub UserControl_ReadProperties ... Public Sub zSubclass_Proc(ByVal bBefore As Boolean, ByRef bHandled As Boolean, ByRef lReturn As Long, ByRef lng_hWnd As Long, ByRef uMsg As Long, ByRef wParam As Long, ByRef lParam As Long) ...
    (microsoft.public.vb.general.discussion)
  • Re: How many timers?
    ... Private PeriodicTasks As New Collection ... Private WithEvents HalfSecond As EventSync ... Private ConnectState As ConnectFlags ... Private Sub Form_Click ...
    (microsoft.public.vb.general.discussion)
  • Re: GUI question (slightly complicated - maybe only for the experts in here)
    ... An invalid drop target is drawn in red. ... Private WithEvents Board As CBoard ... Private mMoving As Boolean ... Private Sub Form_Resize ...
    (microsoft.public.vb.general.discussion)