보오 목록 내보내기 Excel 이후 단위 대량 교체

21775 단어
보오 리스트 V17에서는 단위 ㎡와 ㎥ 숫자가 모두 위에 표시됐다.인쇄된 후 쉽게 분별할 수 있도록 BOSS의 요구에 따라 Excel을 내보낸 후 이를 'm2' 와 'm3' 으로 수정합니다.
VBS 벌크 수정 코드:
Option Explicit

If Wscript.Arguments.Count = 0 Then
    WScript.Echo Chr(10) & _
    "[    ]" & Chr(10) & Chr(10) & _
    Chr(9) & "     Excel      " & Chr(10) & Chr(10) & _
    "[    ]" & Chr(10) & Chr(10) & _
    Chr(9) & "     "
    WScript.Quit
End If

Dim xlsFilePath
xlsFilePath=WScript.Arguments(0)

Dim Wshell
Set Wshell=CreateObject("Wscript.Shell")

If LCase(Right(WScript.FullName,11)) = "wscript.exe" Then
    Wshell.Run "CScript.exe //nologo" & _
    Chr(32) & _
    Chr(34) & WScript.ScriptFullName & Chr(34) & _
    Chr(32) & _
    Chr(34) & WScript.Arguments(0) & Chr(34)
    WScript.Quit
End If

WScript.Echo "    ,   ......"

Dim oExcel,oWorkbook,Sheet
On Error Resume Next
Set oExcel = GetObject(,"Excel.Application")
If Err Then
    WScript.Echo Err.Description
    Err.Clear
    Set oExcel = CreateObject("Excel.Application")
    oExcel.Visible = False
End If
Set oWorkbook = oExcel.Workbooks.Open(xlsFilePath)
If Err Then
    Err.Clear
    Wshell.Popup "         ,      :" & Chr(10) & _
    "1、      Microsoft Office 2003、2007、2010     。" & Chr(10) & _
    "2、                   ,             。", 10 , "  ", 16+4096
    WScript.Quit
End If
On Error Goto 0
oExcel.DisplayAlerts = False

Dim CurrentPath
CurrentPath = CreateObject("Scripting.FileSystemObject").GetFile(Wscript.ScriptFullName).ParentFolder.Path
For Each Sheet In oWorkbook.Worksheets
    Sheet.Activate
    Wscript.Echo "Replace:" & Sheet.Name
    oExcel.Cells.Replace "", "m2", 2, 1, False, False, False
    oExcel.Cells.Replace "", "m2", 2, 1, False, False, False
    oExcel.Cells.Replace "", "m3", 2, 1, False, False, False
    oExcel.Cells.Replace "   ", "m", 2, 1, False, False, False
Next
oWorkbook.Worksheets(1).Select
oWorkbook.Save
oExcel.DisplayAlerts = True
oWorkbook.Close

Set oExcel = Nothing
Set oWorkbook = Nothing

Wshell.Popup "           ,            。", 10, "      ", 48

VBS 대량 수정 코드(교체 목록.txt 파일 읽기, 반복 교체)
Option Explicit

If Wscript.Arguments.Count = 0 Then
    WScript.Echo Chr(10) & _
    "[    ]" & Chr(10) & Chr(10) & _
    Chr(9) & "     Excel      " & Chr(10) & Chr(10) & _
    "[    ]" & Chr(10) & Chr(10) & _
    Chr(9) & "     "
    WScript.Quit
End If

Dim xlsFilePath
xlsFilePath=WScript.Arguments(0)

Dim Wshell
Set Wshell=CreateObject("Wscript.Shell")

If LCase(Right(WScript.FullName,11)) = "wscript.exe" Then
    Wshell.Run "CScript.exe //nologo" & _
    Chr(32) & _
    Chr(34) & WScript.ScriptFullName & Chr(34) & _
    Chr(32) & _
    Chr(34) & WScript.Arguments(0) & Chr(34)
    WScript.Quit
End If

WScript.Echo "    ,   ......"

Dim oExcel,oWorkbook,Sheet

On Error Resume Next

Set oExcel = GetObject(,"Excel.Application")
If Err Then
    WScript.Echo Err.Description
    Err.Clear
    Set oExcel = CreateObject("Excel.Application")
    oExcel.Visible = False
End If

Set oWorkbook = oExcel.Workbooks.Open(xlsFilePath)
If Err Then
    Err.Clear
    Wshell.Popup "         ,      :" & Chr(10) & _
    "1、      Microsoft Office 2003、2007、2010     。" & Chr(10) & _
    "2、                   ,             。", 10 , "  ", 16+4096
    WScript.Quit
End If

On Error Goto 0

Dim fso,oFile
Set fso = CreateObject("Scripting.FileSystemObject")

Dim strLine
Dim strArr

Dim CurrentPath
CurrentPath = CreateObject("Scripting.FileSystemObject").GetFile(Wscript.ScriptFullName).ParentFolder.Path

oExcel.DisplayAlerts = False
For Each Sheet In oWorkbook.Worksheets
    Sheet.Select
    Sheet.Activate
    WScript.Echo Sheet.Name
    Set oFile = fso.OpenTextFile(CurrentPath & "\    .txt", 1)
    Do While oFile.AtEndOfStream <> True
        strLine = oFile.ReadLine
        strArr = Split(strLine,"")
        oExcel.Cells.Replace strArr(0), strArr(1), 2, 1, False, False, False
    Loop
    oFile.Close
Next
oWorkbook.Worksheets(1).Select
oWorkbook.Save
oExcel.DisplayAlerts = True
oWorkbook.Close

Set oFile = Nothing
Set oExcel = Nothing
Set oWorkbook = Nothing

Wshell.Popup "           ,            。", 10, "      ", 48

목록.txt 대체 예:
   04 →04    (   )    
   05 →05    (   )    
   06 →06        
   09 →09        
   11 →11    (   )    
   12 →12    (   )    
   13 →13    (   )    
   15 →15        
   18 →18        
   19 →19    (   )    
   27 →27    (     )    
   28 →28        
   29 →29        
   31 →31    (   )    
   32 →32        
   33 →33    (    )    
   34 →34    (    )    
   35 →35    (    )    
   36 →36    (    )    
   37 →37    (    )    
   38 →38    (    )    
  01→       
  02→       
  03→       
  04→       
  05→       
  06→   (    )    
  07→   (    )    
  08→   (  )    
  09→   (  )    
  10→       
  11→        
  12→        
  13→        
   →       
     →      
     →     
     →  
     →    
     →  
     →  
     →  
     →  
㎡→m2
→m2
→m3

 
전재 대상:https://www.cnblogs.com/cnrsgx/p/5741149.html

좋은 웹페이지 즐겨찾기