VBA declaration order of "Attribute VB_Control"s keeps changing

PMBottas

New Member
Joined
Jul 4, 2014
Messages
2
Hi,
Does anyone know why would the declaration order of the Attribute VB_Control... statements would change.
I'm not deleting or adding any controls but it seems every time that I click one or more of them , the declaration order in the module changes.
This happens in any and all worksheet modules.

For example this:
Code:
Attribute VB_Name = "WS__Schedule"
Attribute VB_Base = "0{00020820-0000-0000-C000-000000000046}"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = True
Attribute VB_TemplateDerived = False
Attribute VB_Customizable = True
Attribute VB_Control = "bttnDeleteScheduleEntry, 13, 0, MSForms, CommandButton2"
Attribute VB_Control = "bttnAddScheduleEntry, 12, 1, MSForms, CommandButton2"
Attribute VB_Control = "bttnCalculateShortages, 10, 2, MSForms, CommandButton2"
Attribute VB_Control = "spinAdjustPriority, 6, 3, MSForms, SpinButton2"
Attribute VB_Control = "bttnModifyScheduleEntry, 15, 4, MSForms, CommandButton2"
[\code]

becomes this
[code]
Attribute VB_Name = "WS__Schedule"
Attribute VB_Base = "0{00020820-0000-0000-C000-000000000046}"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = True
Attribute VB_TemplateDerived = False
Attribute VB_Customizable = True
Attribute VB_Control = "spinAdjustPriority, 6, 0, MSForms, SpinButton2"
Attribute VB_Control = "bttnCalculateShortages, 10, 1, MSForms, CommandButton2"
Attribute VB_Control = "bttnAddScheduleEntry, 12, 2, MSForms, CommandButton2"
Attribute VB_Control = "bttnDeleteScheduleEntry, 13, 3, MSForms, CommandButton2"
Attribute VB_Control = "bttnModifyScheduleEntry, 15, 4, MSForms, CommandButton2"
'---------------------------------------------------------------------------------------
[\code]


Now, this may seem like a small thing, a non-starter even, except that I have the workbook under source code control. So, when I go and 'diff' the working copy, it show a change in a module that I'm 99.99999% sure that I made no changes in, yet it forces me to go look.

Any ideas what the underlying cause is and is there anyway to stop it?

Thanks in advance
Paul
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
i don't know how it happens. maybe you can try this solution.
Code:
dim a as string, b as string, c as string
a="xxx"
b="yyy"
c="zzz"
Attribute VB_1=a
Attribute VB_2=b
Attribute VB_3=c
 
Upvote 0
ww4612 : Thanks for the suggestion, but it doesn't work.

As you have it, it generates an error as the code is outside a procedure (as the Attribute statement is in the module header and you can't have Dims and Assignment statements there), so I tried this:
Code:
Private Const attribBttnModifyScheduleEntry as String = "bttnModifyScheduleEntry, 15, 0, MSForms, CommandButton2"
Attribute VB_Control = attribBttnModifyScheduleEntry

but that throws a runtime error #32809...which I believe indicates that the workbook is corrupt...

but thanks again!

Does anyone else have any input on this?
Paul

Afterthought... hmmm... maybe add the controls dynamically at workbook open? I assume that this can be done, correct?
 
Last edited:
Upvote 0
Did you ever find anything out with this? I have a similar problem, but instead of just being rearranged it deletes the attributes for my command buttons and combobox
 
Upvote 0

Forum statistics

Threads
1,214,908
Messages
6,122,187
Members
449,071
Latest member
cdnMech

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top