I have a number of excel files containing filled survery, now I would like to have one master document that would have summary result of each.
Thus I imaging to have for
You are on the right track. It is not difficult and I don't think there is an easier way to get data from another workbook. Write a function and you can reuse the code easily.
If the macros are only needed to compile the survey data, you can remove the macros from the xls file that is filled out. Otherwise you will need to modify the security permissions on each computer or digitally sign the project.
Those are at least 4 questions in one, let's see what we can do about it :-)
First, there is no need to create another Excel instance, just add your code into an empty workbook (or into your master document, if that's ok for you)
Public Function OpenWorkbook(mypath As String) As Workbook
Workbooks.Open Filename:=mypath
Set OpenWorkbook = ActiveWorkbook
End Function
Usage:
Dim wb as workbook, ws as worksheet
set wb = OpenWorkbook("your path")
set ws = wb.Sheets(1)
Avoiding the 2nd Excel instance automatically solves your problem with any VBA macros in your survey documents - when you open another workbook from within a running macro like the way above, the user won't get any security warning. (By the way, do the survey documents have to contain any macros?)
Copying data from that sheet into your workbook goes like this:
ThisWorkbook.Sheets("Name of your sheet").Range("A1") = ws.Range("A1")
Iterating through a bunch of Excel files in a folder is described, for example, here
Hope that helps.