Skip to content

Commit

Permalink
Cleaned up code a bit.
Browse files Browse the repository at this point in the history
Added some comments and renamed the form, buttons and subs to be a
little more explicit.
  • Loading branch information
Kurt M. committed Apr 6, 2014
1 parent 7846129 commit 718bf8f
Show file tree
Hide file tree
Showing 4 changed files with 193 additions and 177 deletions.
3 changes: 2 additions & 1 deletion Module1.bas
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Attribute VB_Name = "Module1"
' Sub to launch mainUserForm when Add-In is selected.
Sub CallUserForm()
formStep1.Show
mainUserForm.Show
End Sub
66 changes: 30 additions & 36 deletions ThisWorkbook.cls
Original file line number Diff line number Diff line change
Expand Up @@ -12,51 +12,45 @@ Option Explicit
Dim cControl As CommandBarButton



' Execute this function when user selects to install Add-In.
' This will create the Menu Bar button for this utility.
Private Sub Workbook_AddinInstall()



On Error Resume Next 'Just in case

'Delete any existing menu item that may have been left.

Application.CommandBars("Worksheet Menu Bar").Controls("ai-one Excel-To-File Converter").Delete
Application.CommandBars("Worksheet Menu Bar").Controls("ai-one Excel-To-File").Delete

'Add the new menu item and Set a CommandBarButton Variable to it

Set cControl = Application.CommandBars("Worksheet Menu Bar").Controls.Add

'Work with the Variable

With cControl

.Caption = "ai-one Excel-To-File Converter"

.Style = msoButtonCaption

.OnAction = "CallUserForm"

'Macro stored in a Standard Module

End With



On Error Resume Next 'Just in case

'Delete any existing menu item that may have been left.

Application.CommandBars("Worksheet Menu Bar").Controls("ai-one Excel-To-File Converter").Delete

'Add the new menu item and Set a CommandBarButton Variable to it

Set cControl = Application.CommandBars("Worksheet Menu Bar").Controls.Add

'Work with the Variable

With cControl

.Caption = "ai-one Excel-To-File Converter"

.Style = msoButtonCaption

.OnAction = "CallUserForm"

'Macro stored in a Standard Module

End With

On Error GoTo 0


End Sub

' This Sub executes when a user selects to uninstall the Add-In
Private Sub Workbook_AddinUninstall()

On Error Resume Next 'In case it has already gone.

Application.CommandBars("Worksheet Menu Bar").Controls("ai-one Excel-To-File Converter").Delete


On Error Resume Next 'In case it has already gone.

Application.CommandBars("Worksheet Menu Bar").Controls("ai-one Excel-To-File Converter").Delete

On Error GoTo 0

End Sub
Loading

0 comments on commit 718bf8f

Please sign in to comment.