Dim fs: Set fs = CreateObject("Scripting.FileSystemObject")
Dim tso: Set tso = fs.OpenTextFile("C:\xxx\AllReportsControls.txt", 2, True)
Dim ct As DAO.Container
For Each ct In CurrentDb.Containers
If ct.Name = "Reports" Then
Dim doc As DAO.Document
For Each doc In ct.Documents
Debug.Print doc.Name
tso.WriteLine ""
tso.WriteLine "帳票名" & vbTab & doc.Name
DoCmd.OpenReport doc.Name, acViewDesign, , , acHidden
Dim rpt As Report: Set rpt = Reports(doc.Name)
tso.WriteLine "RecordSource" & vbTab & rpt.RecordSource
tso.WriteLine "Type" & vbTab & "名称" & vbTab & "Source/Caption"
Dim obj As Control
For Each obj In rpt
Select Case TypeName(obj)
Case "TextBox"
tso.WriteLine TypeName(obj) & vbTab & obj.Name & vbTab & obj.ControlSource
Case "Label"
tso.WriteLine TypeName(obj) & vbTab & obj.Name & vbTab & obj.Caption
End Select
Next
DoCmd.Close acReport, doc.Name
Next doc
Exit For
End If
Next
tso.Close
Set tso = Nothing
Set fs = Nothing