zoukankan      html  css  js  c++  java
  • VBA之三

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

    Function InsertIntoDoc(strPath as String)

    Set fso=CreateObject("Scripting.FileSystemObject”)

    Set objFolder=fso.GetFolder(strPath)

    Set objFiles =objFolder.Files

    Str1=””

    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 Function

    Sub CommandButton1_Click()

    Call InsertIntoDoc(路径)

    End Sub

    Function InsertIntoDoc(strPath as String)

    Set fso=CreateObject("Scripting.FileSystemObject”)

    Set objFolder=fso.GetFolder(strPath)

    Set objFiles =objFolder.Files

    Str1=””

    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 Function

    Sub CommandButton1_Click()

    Call InsertIntoDoc(路径)

    End Sub

  • 相关阅读:
    java 命令
    测试事件响应修改界面内容
    ASP.NET MVC 解决账号重复登录问题
    Redis 安装
    js返回页面顶部
    Brackets 前端编辑器推荐
    一点点............
    响应式——em,rem,px
    新知识——响应式
    面试心得
  • 原文地址:https://www.cnblogs.com/djcsch2001/p/2114402.html
Copyright © 2011-2022 走看看