View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
paul mullan paul mullan is offline
external usenet poster
 
Posts: 7
Default Problem in adding macro to ribbon through Add-in

Hi -

I am using the following simple code to protect and unprotect all
worksheets

Sub UnprotectAllSheets()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
ws.Unprotect Password:="2016"
Next ws

End Sub


Sub protectAllSheets()
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
ws.Protect Password:="2016"
Next ws

End Sub


I have tested this in the workbook that it was created in and it is
working fine. I then save as Excel Add-in file so that I can use teh
function in a ribbon in other workbooks.

I load up a workbook and select the add in. I add the bottons to the
ribbon and assign the macro

Now the buttons appear on teh ribbon but have no function i.e. they do
nothing.

Under the developer bar I have checked the 'Macros' button. This shows
no macros listed - though I am not sure if it would as teh macro is
not assigned to the workbook so to speak, but to excel through the add-
in.

If I open VB editor, the codeis visable and all seems correct. However
if i 'run' it, again nothing happens.

The problem seems to be in linking the macro to the ribbon through the
add-in process. This is the first time I have tried thsi so any help
would be greatlyapprecated.

p.s. the workbook this was created in was the default excel sheet with
"sheet 1; sheet 2; sheet 3" as workbook tabs. The workbook I want this
to work on has 55 work sheets with a variety of names. I dont think
this would make a difference but I am stumped ......
Thanks all