VBA code to enable macros

Copper Contributor

I have mentioned the below VBA program to open a file, unhide a tab and then clear the contents from a particular cell. but since the option to allow macros is not enabled by default and I cannot change the settings due to company work settings. Also after that the excel file which needs to be opened asks if we need to update links or not. Is there a code which can help me to resolve the attached screenshots.  Due to this I am getting error message at the line Worksheets("All Data").Visible = xlSheetVisible

 

Sub first()
Dim Mainfile As String
Mainfile = Application.GetOpenFilename
Worksheets("All Data").Visible = xlSheetVisible
Dim CelPos1 As Integer
Range("CelPos1").Value = Range("A3").End(xlDown).Row
Range("A3:BOCelPOs1").ClearContents

0 Replies