|
-
Jan 16th, 2013, 05:19 PM
#1
Thread Starter
Registered User
[RESOLVED] Excel addin with userform toolbar - Help with optimizing the interface!!
Hi there,
I am relatively new to Visual Basic coding but I have recently been working on an excel addin that has 9 different tasks to complete. They need to be completed in a specific order and for general cases some of them need to be repeated.
The main problem I have at the moment is that when my userform toolbox appears (I have made the addin automatically start when the workbook is opened) I cannot select the certain cells required for the macros to run. In some cases the user needs to be able to select different cells to troubleshoot or complete the different actions.
Is there a way to "pause" the macro after the Button has been pushed and then resume operations when the user selects the related cell? or Is there a way to allow users to interact with the spreadsheet even when the userform is displayed?
I'm sorry if this doesn't make sense, I'm finding it hard to explain.
Cheers
This is the code for the userform
Code:
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
If Button.Index = 1 Then
Application.Run "SetUp"
ElseIf Button.Index = 2 Then
Application.Run "OpenSIInp"
ElseIf Button.Index = 3 Then
Application.Run "OpenSIRPred"
ElseIf Button.Index = 4 Then
Application.Run "OpenSIJunc"
ElseIf Button.Index = 5 Then
Application.Run "OpenSILayer"
ElseIf Button.Index = 6 Then
Application.Run "SISum"
ElseIf Button.Index = 8 Then
Application.Run "OpenRoomDiagrams"
ElseIf Button.Index = 9 Then
Application.Run "OpenPath"
ElseIf Button.Index = 10 Then
Application.Run "HelpButton"
ElseIf Button.Index = 11 Then
Application.Run "RestoreToolbars"
End
End If
End Sub
-
Jan 17th, 2013, 10:21 AM
#2
Re: Excel addin with userform toolbar - Help with optimizing the interface!!
Excel VBA question moved to Office Development
-
Jan 17th, 2013, 03:39 PM
#3
Re: Excel addin with userform toolbar - Help with optimizing the interface!!
or Is there a way to allow users to interact with the spreadsheet even when the userform is displayed?
yes, set a module level boolean variable, have the macro finish, then in the selection change event check which boolean is set (if any), set it to false and run other appropriate code based on which boolean
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Jan 17th, 2013, 04:57 PM
#4
Thread Starter
Registered User
Re: Excel addin with userform toolbar - Help with optimizing the interface!!
Thanks for the quick reply.
I have seen a few people suggest the same thing in other threads but as I am fairly new to VB, I don't really know where to start in implementing the method.
Would you be able to post a generic example of what you are describing?
I have solved the problem by using 'vbModeless' elsewhere in my project (code below), would there be any potential problems by doing this?
There is another module which launches the userform (UserForm1) which contains the toolbar.
Code:
Sub launchtoolbar()
UserForm1.Show vbModeless
End Sub
This seems to have solved the problem and now the user can access the spreadsheet with the userform open.
Cheers
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|