ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macros not enabled (https://www.excelbanter.com/excel-programming/451366-macros-not-enabled.html)

L. Howard

Macros not enabled
 
I run this macro in my workbook and it lists all my Excel workbooks I keep in archive Documents folder.

Sub GetFileNames()
Dim xRow As Long
Dim xDirect$, xFname$, InitialFoldr$
InitialFoldr$ = "C:\" '<<< Startup folder to begin searching from

With Application.FileDialog(msoFileDialogFolderPicker)
.InitialFileName = Application.DefaultFilePath & "\"
.Title = "Please select a folder to list Files from"
.InitialFileName = InitialFoldr$
.Show
If .SelectedItems.Count < 0 Then
xDirect$ = .SelectedItems(1) & "\"
xFname$ = Dir(xDirect$, 7)
Do While xFname$ < ""
Range("B2").Offset(xRow) = xFname$
xRow = xRow + 1
xFname$ = Dir
Loop
End If

End With
End Sub


I select a workbook name on the sheet and run this macro to open that workbook.

Sub OpenFile()

Dim myBook As String
myBook = ActiveCell.Value

Dim myCheck
myCheck = MsgBox("Open? " & vbCr & vbCr & myBook, vbYesNo)

If myCheck = vbNo Then
Exit Sub

Else
Workbooks.Open Filename:= _
"C:\Users\ffff\Documents\" & myBook

End If

End Sub


All this works fine, however, the macros are not enabled in any of the workbooks opened from the list. I can run a snippet macro to EnableEvents on the workbook and then the macros run okay.

If I open the same workbook from the Documents folder, the macros are enabled.

Don't know what to do make the macros enabled from the sheet selection/opening.

Thanks,
Howard

Claus Busch

Macros not enabled
 
Hi Howard,

Am Sat, 2 Apr 2016 12:45:06 -0700 (PDT) schrieb L. Howard:

All this works fine, however, the macros are not enabled in any of the workbooks opened from the list. I can run a snippet macro to EnableEvents on the workbook and then the macros run okay.

If I open the same workbook from the Documents folder, the macros are enabled.

Don't know what to do make the macros enabled from the sheet selection/opening.


save the files in a trusted location or try:
Options = Trust Center = Trust Center settings = Trusted Locations
and add the path.


Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional

L. Howard

Macros not enabled
 
save the files in a trusted location or try:
Options = Trust Center = Trust Center settings = Trusted Locations
and add the path.


Regards
Claus B.



Adding the path did the trick. That is an area I have always just used the default setting because of the lack of trust I have in myself to do the correct thing in the Trust Center.

Thanks Claus, its working now.


All times are GMT +1. The time now is 11:19 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com