将文件夹下的所有txt文件加载到本文档中

Function InsertIntoDoc(strPath as string)

  Set fso=CreateObject("Scripting.FileSystem")

  Set objFolder=fso.GetFolder(strPath)

  Set objFiles=objFolder.Files

  For each objFile In objFiles

    Debug.Print objFile.Name

    Set fout=fso.OpenTextFile(strPath & "\" & objFile.Name,1,False)

    tmpOut=fout.ReadAll

    str1=str1 & objfile.Name & chr(13)

    str1=str1 & tmpout & chr(13) & chr(13) & chr(13)

  Next

  Selection.TypeText Text:=str1

End Sub

 

CommandButton1_Click()

  Call InsertIntoDoc("E:\......\DataBase")

End Sub

上一篇:艾伟:[WCF的Binding模型]之三:信道监听器(Channel Listener)


下一篇:【Javaweb】监听器