Indeed, the problems were due to my macros being inside a plugin. Here's the final logic that can grab named ranges inside closed workbooks and copy them into another (open) workbook.
I've also included a copy of the debug macro that did not work, for the cleanest example of referencing a workbook from within a plugin (where "ThisWorkbook" will not work):
Public Sub GetDataFromClosedWorkbook()
Dim wb As Workbook
Dim wks As Worksheet
Dim path As String
Application.ScreenUpdating = False ' turn off the screen updating
path = "C:\Documents and Settings\senft100\My Documents\blakieto\jobCosting\TD Forecast\"
Set wb = Workbooks.Open(path & "AnimLayTDForecast.xls", True, True) ' open the source workbook, read only
' copy the staff schedules from the opened workbook into the department sheet of the summary workbook:
wb.Worksheets("AnimLay Schedule").Range("Staff").Copy _
Application.Workbooks("SummaryTDForecast.xls").Worksheets("AnimLay Schedule").Range("Staff")
wb.Close False ' close the source workbook without saving any changes
Set wb = Nothing ' free memory
Calculate ' force a worksheet recalculation
Application.ScreenUpdating = True ' turn on the screen updating
End Sub
Public Sub WorksheetsReport()
Dim i As Integer
Dim wb As String
wb = "SummaryTDForecast.xls"
For i = 1 To Application.Workbooks(wb).Worksheets.Count
MsgBox Application.Workbooks(wb).Worksheets(i).Name & " has index = " & Application.Workbooks(wb).Worksheets(i).Index
Next i
End Sub
Note: the 'Calculate' at the end of the routine forces the copied cells to update themselves. Necessary to keep the users from asking why the function does not work! (Even though they could just press F9... but this does that for them.)
Cheers!
-Blakieto