Change Trust Center Settings with VBA

erkala

New Member
Joined
Mar 9, 2012
Messages
4
I have a pivot table that needs specific settings in the Trust Center. It requires "Enable all macros" and trust access. I have an existing macro that opens this file to extract data. Is there a VBA that would update the Trust Center to allow for this file then revert back to the old settings. I do not want to enable all macros all the time.

Thanks!!
erkala
 
Last edited:

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
erkala,

Something like this?
Code:
Sub tgr()
 
    Dim MacroSec As Integer
 
    MacroSec = Application.AutomationSecurity
    Application.AutomationSecurity = msoAutomationSecurityLow
 
    '''''''''''''''''''''
    '                   '
    '   Run code here   '
    '                   '
    '''''''''''''''''''''
 
    Application.AutomationSecurity = MacroSec
 
 
End Sub
 
Upvote 0
erkala,

Something like this?
Code:
Sub tgr()
 
    Dim MacroSec As Integer
 
    MacroSec = Application.AutomationSecurity
    Application.AutomationSecurity = msoAutomationSecurityLow
 
    '''''''''''''''''''''
    '                   '
    '   Run code here   '
    '                   '
    '''''''''''''''''''''
 
    Application.AutomationSecurity = MacroSec
 
 
End Sub

Worked!! Thanks a ton!!
 
Upvote 0
I tried the code to auto enable editing for files originating from the internet but to no avail. Would you please help me with my problem? Thanks in advance!
 
Upvote 0

Forum statistics

Threads
1,223,750
Messages
6,174,290
Members
452,554
Latest member
Louis1225

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