Enable macro in Excel

RobSA

Board Regular
Joined
Sep 2, 2012
Messages
91
Hi Folks,

I have created macros, in an excel workbook, that when action-ed, give me the error, macros are not enabled or not available in this workbook.
I have gone through all the "trusted setting" and made the adjustment accordingly, however the problem remains.
I would appreciate your inputs that I can get past this impasse.

Regards
Rob
 
Thanks Rory,

Sorry for all the issues, thanks for the revised code.

I have tried to make the change in my two macro's but with the change provided, I can see the module information however it does no longer show the macro, if i try run it
 
Upvote 0

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
If you need to be able to run it manually as well, then you should create a separate callback and have that call your existing macro. The onAction for your ribbon control should be the name of the callback, not the macro.
 
Upvote 0
Hi Rory,

I am not someone who knows much or anything about the call back /coding on actions details. I also do not know what you mean by manually.

What I am trying to do is basically ste up a ribbon which has icons on, that when selected will open a file, be it a word document, pdf or excel file itself.

I thinsk you for all your response and guidence thus far
 
Upvote 0
Hi Rory,


I have reverted back to the original macro, by changing the first line

VBA Code:
 Sub Macro_1(ByVal control as IRibbonControl)
and removed the section between (), this now allows me to see the macros numbers, when in design mode.

The function though is still where it was.
 
Upvote 0
Hi Rory,
In follow up to our previous discussions, I have explored further and made some changes, as follows:

In the UI editor, I just wrote the on Action -"Macro_1"

VBA Code:
<toggleButton id="Togglebutton287" imageMso="SaveAsRichText" label="QM 01   - Index" [B]onAction="Macro_1[/B]"/>

I also then selected the generate call back function in the UI editor, which then created a call back item looking like this:

VBA Code:
'Callback for [B]Togglebutton287 onAction[/B]
Sub Macro_1(control As IRibbonControl, pressed As Boolean)
End Sub

I think this is the part of the exercise you were referring to in having a call back with the same name.

In terms of the Macro itself, it seems to function correctly except for the fact that the selected action does not bring the file to the front of the screen, but remains hidden behind.

VBA Code:
Sub [B]Macro_1(control As IRibbonControl, pressed As Boolean)[/B]
Dim WordDoc As Object
Set WordDoc = CreateObject("Word.Application")
WordDoc.Documents.Open "C:\Users\User\Desktop\EPOCH_01_INDEX_2020.docx"
WordDoc.Visible = True
End Sub

It would be appreciated if you would comment on the changes made, for their improvement. As already mentioned I would like to get the operational side of things getting pdf's, other word documents and excel sheets to be opened in a similar fashion.

Thanks again for your previous support and inputs.
 
Upvote 0

Forum statistics

Threads
1,214,606
Messages
6,120,490
Members
448,967
Latest member
visheshkotha

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