- Sub test()
-
- ' 创建文件系统对象的实例
- Dim fso As Object
- Set fso = CreateObject("Scripting.FileSystemObject")
-
- ' 打开文本文件
- Dim ts As Object
- Set ts = fso.OpenTextFile("cad.txt")
-
- ' 循环读入每一行,判断文件是否存在,存在则打开
- Dim s As String
- Do While Not ts.AtEndOfStream
- s = ts.ReadLine
- If fso.fileexists(s) Then Application.Documents.Open s
- Loop
- ts.Close
- Set ts = Nothing
- Set fso = Nothing
- End Sub
|