Hi everyone...
It's great to see such a good site...
steve
This is NOT an ADD for my project nor is it spam its just a very good thing... i know its a bit long winded Blah Blah
i thought others might find the following useful... and i hope you enjoy the twisted use of the left right and mid string functions.
Warning if you are creating toolbars and or buttons and don't want to lose them i suggest you seek out your exel11.xlb and copy it to a safe place or as can happen when you get and application level error you can lose all your changes also note that if you open excel quickly after closing it you can also lose your toolbar customizations. Note: That your changes are saved into a global file not into the spreadsheet itself so any changes you make will also appear in any other spreadsheet but they may not work as the macros attached to the buttons might not be available. Often just to confuse everyone clicking a button in a new spread sheet will or may open another sheet in which the macros actually reside.
I had written a series of macro's to automatically create a 12month invoicing database (1 sheet for each month)... with default formula and formatting. The database will be used by subcontractors to invoice clients.
The Settings Toolbar
-- removed inline image ---
i achieve this by having a month template sheet that is copied after the last sheet then edited (in code) to suit the month. this is done in a For Each loop.
Once the year is created by the code the toolbar that controls months (which also contains a create invoice button) appears and you are then able to create invoices.. Invoices are also automatically created using the same template sheet process of copying the sheet and renaming it ... this is driven by a settings sheet which keeps track of the invoice numbers (incrementing each time an invoice is created)'
Both the year and any or all invoices can be exported (printed) from a custom print dialog that adjusts itself according to if a Month is shown or an invoice is the activesheet.
Invoice creation is achieved by entering the data into a custom form thusly no actual data entry is possible on the sheets themselves maintaining transparent security and data integrity by protecting and unprotecting sheets on the fly or as needed.
To locate an invoice all you do is click an an invoice number on the month sheet to load that invoice as the active sheet.
so as can be seen it is quite a good project..
Soooo i was trying to find a way to transfer my macros and toolbars to another system without using the personal spreadsheet or creating code to export the macros then import them on another machine so i came up with the following procedure. after getting some clues as to how to proceed from the web.
Since my project already has a procedure to change the toolbar buttons and make toolbars visible/invisible on the fly i simply re-assign the macros to the new file location within the macro looping on the toolbars controls.count... i.e
So below you will see that it first loops on the toolbars themselves when it finds one of mine it then loops on it's controls.count, fnishs that loop and grabs another toolber to loop on.
It's great to see such a good site...
steve
This is NOT an ADD for my project nor is it spam its just a very good thing... i know its a bit long winded Blah Blah
i thought others might find the following useful... and i hope you enjoy the twisted use of the left right and mid string functions.
Warning if you are creating toolbars and or buttons and don't want to lose them i suggest you seek out your exel11.xlb and copy it to a safe place or as can happen when you get and application level error you can lose all your changes also note that if you open excel quickly after closing it you can also lose your toolbar customizations. Note: That your changes are saved into a global file not into the spreadsheet itself so any changes you make will also appear in any other spreadsheet but they may not work as the macros attached to the buttons might not be available. Often just to confuse everyone clicking a button in a new spread sheet will or may open another sheet in which the macros actually reside.
I had written a series of macro's to automatically create a 12month invoicing database (1 sheet for each month)... with default formula and formatting. The database will be used by subcontractors to invoice clients.
The Settings Toolbar
-- removed inline image ---
i achieve this by having a month template sheet that is copied after the last sheet then edited (in code) to suit the month. this is done in a For Each loop.
Once the year is created by the code the toolbar that controls months (which also contains a create invoice button) appears and you are then able to create invoices.. Invoices are also automatically created using the same template sheet process of copying the sheet and renaming it ... this is driven by a settings sheet which keeps track of the invoice numbers (incrementing each time an invoice is created)'
Both the year and any or all invoices can be exported (printed) from a custom print dialog that adjusts itself according to if a Month is shown or an invoice is the activesheet.
Invoice creation is achieved by entering the data into a custom form thusly no actual data entry is possible on the sheets themselves maintaining transparent security and data integrity by protecting and unprotecting sheets on the fly or as needed.
To locate an invoice all you do is click an an invoice number on the month sheet to load that invoice as the active sheet.
so as can be seen it is quite a good project..
Soooo i was trying to find a way to transfer my macros and toolbars to another system without using the personal spreadsheet or creating code to export the macros then import them on another machine so i came up with the following procedure. after getting some clues as to how to proceed from the web.
Since my project already has a procedure to change the toolbar buttons and make toolbars visible/invisible on the fly i simply re-assign the macros to the new file location within the macro looping on the toolbars controls.count... i.e
Code:
For i = 1 To .Controls.Count '- 1
'get the position of the ! in the OnAction setting
instrExclam = InStr(.Controls(i).OnAction, "!")
'reconstruct the Onaction setting and reset it to the current workbook
.Controls(i).OnAction = ActiveWorkbook.FullName & "!" & Right(.Controls(i).OnAction, Len(.Controls(i).OnAction) - instrExclam)
Someone may find this useful
This is the entire toolbar button_enabler macro code
Code:
Dim Cbar As CommandBar, strSheetID As String, i As Integer, instrExclam As Integer
For Each Cbar In Application.CommandBars
On Error Resume Next[INDENT]
'
[/INDENT][INDENT] 'StrsheetName = Right(Mid(StrsheetName, 2, 11), 4)
[/INDENT]'If InStr(StrsheetName, "Thru") <> 0 Then
With Cbar 'find the custom control button and disable it
'Set the toolbar to act upon
Select Case .Name
Case "System Manager"
'Which Sheet has sent the call to the procedure
Select Case StrsheetName
'The Sheet is the settings sheet
Case "Settings"
'"System Manager Toolbar"
For i = 1 To .Controls.Count '- 1
instrExclam = InStr(.Controls(i).OnAction, "!")
.Controls(i).OnAction = ActiveWorkbook.FullName & "!" & Right(.Controls(i).OnAction, Len(.Controls(i).OnAction) - instrExclam)
Select Case i
Case 1, 2, 4, 5, 6, 7, 9
.Controls(i).Enabled = True
.Controls(i).Visible = True
Case Else
.Controls(i).Enabled = False
.Controls(i).Visible = False
End Select
Next i
' Case "Months Exist"
' '"System Manager Toolbar settings if Months exist"
' For i = 1 To .Controls.Count - 1
' Select Case i
' Case 1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12
' .Controls(i).Enabled = True
' .Controls(i).Visible = True
' Case Else
' .Controls(i).Enabled = False
' .Controls(i).Visible = False
' End Select
' Next i
Case "Nil_Months_Exist"
'"System Manager Toolbar settings if no Months exist"
For i = 1 To .Controls.Count '- 1
instrExclam = InStr(.Controls(i).OnAction, "!")
.Controls(i).OnAction = ActiveWorkbook.FullName & "!" & Right(.Controls(i).OnAction, Len(.Controls(i).OnAction) - instrExclam)
Select Case i
Case 5 ', 2, 3, 6, 7, 8, 9, 10
.Controls(i).Enabled = True
.Controls(i).Visible = True
Case Else
.Controls(i).Enabled = False
.Controls(i).Visible = False
End Select
Next i
Case "Thru"
For i = 1 To .Controls.Count
instrExclam = InStr(.Controls(i).OnAction, "!")
.Controls(i).OnAction = ActiveWorkbook.FullName & "!" & Right(.Controls(i).OnAction, Len(.Controls(i).OnAction) - instrExclam)
Select Case i
Case 3, 4, 6, 7, 8, 9, 10, 11, 12
.Controls(i).Enabled = True
.Controls(i).Visible = True
Case Else
.Controls(i).Enabled = False
.Controls(i).Visible = False
End Select
Next i
Case "Proteus"
'MsgBox "Invoice"
End Select
Case "Invoice Manager"
For i = 1 To .Controls.Count - 1
instrExclam = InStr(.Controls(i).OnAction, "!")
.Controls(i).OnAction = ActiveWorkbook.FullName & "!" & Right(.Controls(i).OnAction, Len(.Controls(i).OnAction) - instrExclam)
.Controls(i).Enabled = True
.Controls(i).Visible = True
Next i
Case Else
For i = 1 To .Controls.Count - 1
instrExclam = InStr(.Controls(i).OnAction, "!")
.Controls(i).OnAction = ActiveWorkbook.FullName & "!" & Right(.Controls(i).OnAction, Len(.Controls(i).OnAction) - instrExclam)
.Controls(i).Enabled = True
Next i
End Select
End With
On Error GoTo 0
Next Cbar
Incidentally because my project has template sheets in it and i copied the excel 11.xlb over it runs without any problems. You may however run into some references problems in the vba editor. However anyone who can understand the code above won't have a problem me thinks.1. To get the macro's onto the new system Save your sheet as an xla
2. Copy the xla to the target system.
3. open a new sheet Add the xla you created to your Addins using the Tools\Addin Menu.
4. copy your excel11.xlb to the folder you want on the target system..if you want to write code to change or save the xlb on the fly while opening or closing your project that's up to you of course.5. Have fun.
Last edited: