zoukankan      html  css  js  c++  java
  • word文档批量合并工具

    #NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.  
    ; #Warn  ; Enable warnings to assist with detecting common errors.  
    SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.  
    SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.  
      
    #SingleInstance Force  
    FileInstall ,D:2 IE天使ICO图标制作ICO图标文件2ICO2s023.ico,c:3.ico,1  
    If fileExist("C:3.ico")  
        Menu, Tray, Icon, c:3.ico, , 1  ;显示图标  
    try   
    {  
        wd:=ComObjActive("word.Application")  
    }catch e{  ;用于捕获错误,未启动word就抛出!!!  
        MsgBox 当前未启动word,请先打开word,注意不是WPS!!!  
        return  
    }  
    SetWorkingDir %A_ScriptDir%  
    Gui Font, s13  
    Gui Add, Text, x150 y1 w538 h50 +0x200, word文档合并工具  ;后面可修饰字体颜色,字号等;  
    Gui, Add, Checkbox, x60 y175 w200 h20  v子文件夹 checked, 合并子文件夹中的文档  
    Gui, Add, Checkbox, x300 y175 w200 h20  v扩展名, 显示扩展名  
    Gui Add, Button, x144 y205 w160 h70  g开始合并, 开始合并  
    Gui Font  
    Gui Font, s14  
    Gui Add, Text, x28 y44 w538 h50 +0x200, 将要合并的文件夹拖入,或者定位文件夹(必须先打开word)  
    Gui Font  
    Gui Add, Edit, x32 y112 w366 h49 vEdit1  
    Gui Add, Button, x407 y118 w75 h47 g定位, 定位  
    Gui Show, w550 h314, Word文档合并工具  
    Return  
    ;autogui如何反相生成gui?  
    GuiEscape:  
    GuiClose:  
        ExitApp  
      
    ; End of the GUI section  
    开始合并:  
    Gui, Submit  
      
    doc0:=wd.documents.add  
    Loop  ,%Edit1%*.doc*, 0, %子文件夹% ;第三个参数:0-仅文件;1-文件+文件夹;2-仅文件夹,但是若是前面仅仅给出个母文件夹的话,可以但限制了具体文件后缀的话2就无效了;最后一个为1时为递归;  
    {  
        st:=doc0.range.end-1  
        if(扩展名=1)  
            doc0.range.InsertAfter(A_LoopFileName "`r`n")  ;带扩展名  
        else  
            doc0.range.InsertAfter(RegExReplace(A_LoopFileName,"`ami)..*$") "`r`n")  ;不带扩展名  
          
          doc0.Range(st,doc0.range.end-1).Style := ("标题 2")  
          doc0.Range(st,doc0.range.end-1).Font.Color:=255 ;0x0000FF ;RGB(255, 0, 0)  
        doc0.range(doc0.range.end-1,doc0.range.end-1).Insertfile(A_LoopFileLongPath) ;插入文件  
    }  
    WinActivate, % doc0.name  ;激活文档  
    MsgBox  "已完成!!!"   
    ;~ doc0.saveas "c:	esd.doc"  
    return  
      
    定位:  
    FileSelectFolder,fod,,3,文件夹选择 ;FileSelectFolder, OutputVar, ::{20d04fe0-3aea-1069-a2d8-08002b30309d}  ; 我的电脑.  
    if(fod="")  
        return  
    GuiControl,, Edit1, %fod%  
    return  
      
      
    GuiDropFiles:  ; 对拖放提供支持.经典代码★★★★★★★★★★★★※※※※※※  
    SelectedFileName := A_GuiEvent  
    ;获取鼠标下面的控件★★★★★★★★★★★★★★★★★★★★★  
    MouseGetPos, , , id, control  
    ;~ WinGetTitle, title, ahk_id %id%  
    WinGetClass, class, ahk_id %id%  
    ;~ ToolTip, ahk_id %id%`nahk_class %class%`n%title%`nControl: %control%  
    if (control="Edit1")  
    {  
        GuiControl,, Edit1, %SelectedFileName%  ; 在控件中显示文本.  
    }  
    if (control="Edit2")  
    {  
        GuiControl,, Edit2, %SelectedFileName%  ; 在控件中显示文本.  
    }  
    return  
  • 相关阅读:
    mysql索引最左匹配的理解(转载于知乎回答)
    mysql深度优化与理解(迄今为止读到最优秀的mysql博客)
    PHP数组函数总结与使用
    进程(process)和线程(thread)
    联合索引使用规则(转载)
    mysql优化大全(转自别人 )
    HTTP隧道解决的问题
    HTTP代理协议 HTTP/1.1的CONNECT方法
    vant弹窗提示
    vue获取验证码倒计时
  • 原文地址:https://www.cnblogs.com/zhanglei1371/p/6664860.html
Copyright © 2011-2022 走看看