Disable TabStrip tabs when code is running

Sharid

Well-known Member
Joined
Apr 22, 2007
Messages
1,064
Office Version
  1. 2016
Platform
  1. Windows
In the past I have used this to disable multipage pages while a code is running. This only leave the active PAGE active and disables all the other pages until the process is finished, This prevents the user from navigating to other pages on a Multipage. I have now replaced the Multipage with a tab strip and was trying to do the same. However I can not get it to work.
VBA Code:
Private Sub CommandButton1_Click()
InActivePagesEnabled(MultiPage1) = False ' disable tabs on multipage1
         Application.Run "StaffDetails.UpdateRecords" ' runs this code from module
InActivePagesEnabled(MultiPage1) = True 'enable tabs on multipage1
End Sub

I keep getting an Run type Error 13 Type Mismatch on the first line of code. I tried this
VBA Code:
Private Sub CommandButton1_Click()
InActivePagesEnabled(TabStrip1) = False ' disable tabs on multipage1
         Application.Run "StaffDetails.UpdateRecords" ' runs this code from module
InActivePagesEnabled(TabStrip1) = True 'enable tabs on multipage1
End Sub

And
VBA Code:
Private Sub CommandButton1_Click()
InActivePagesEnabled(UserForm1.TabStrip1) = False ' disable tabs on multipage1
         Application.Run "StaffDetails.UpdateRecords" ' runs this code from module
InActivePagesEnabled(UserForm1.TabStrip1) = True 'enable tabs on multipage1
End Sub
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Instead of disabling why not use a boolean to prevent the code running?
 
Upvote 0
Norie

I'm not sure what you mean. I need the code to run in the module. however I would like to prevent the user from being able to change tabs. The multi page code was a very easy way to disable and enable the pages while the code was running. I was look for a similar simple fix.
 
Upvote 0
Its ok I have done it with this
VBA Code:
''Disable Tabs of Tab strip, only leave active tab TRUE
  Dim oTab As MSForms.Tab
    For Each oTab In UserForm1.TabStrip1.Tabs
        If oTab.Index <> UserForm1.TabStrip1.Value Then
            oTab.Enabled = False
        End If
    Next oTab
          Application.Run "StaffDetails.UpdateRecords" ' runs this code from module 
 ''Enable All Tabs of Tab strip, 
    For Each oTab In UserForm1.TabStrip1.Tabs
        If oTab.Index <> UserForm1.TabStrip1.Value Then
            oTab.Enabled = True
        End If
    Next oTab
 
Upvote 0
Solution
It looks you already have a solution. However, the Enabled property of the TabStrip control might also help.

VBA Code:
UserForm1.TabStrip1.Enabled = False
Application.Run "StaffDetails.UpdateRecords" ' runs this code from module
UserForm1.TabStrip1.Enabled = True
 
Upvote 0
Smozgur

Thanks for your contribution, Just as good as what I did. Only difference is it disables all the tabs on the strip, where as my code, showed the selected tab as active "True" and "False" disabled for all the other tabs.

Either one is as good

Thanks,
 
Upvote 0

Forum statistics

Threads
1,213,534
Messages
6,114,185
Members
448,554
Latest member
Gleisner2

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