| Option Explicit |
| |
| Dim objShell, objFSO, objFolder, objFile, objWord, objDoc, strFolderPath, strFileName, strInitialPath, strDocName |
| Dim objSelection, objRange, objColumns, objPageSetup, objHeaderFooter |
| Dim objDate, strDate, strTime, strDateTime, objCurrentFolder, objCurrentFile, strInputNumber, strHistoryFolderPath |
| |
| |
| Set objShell = CreateObject("Shell.Application") |
| |
| |
| Set objFSO = CreateObject("Scripting.FileSystemObject") |
| |
| |
| strInitialPath = objFSO.GetParentFolderName(WScript.ScriptFullName) |
| |
| |
| strHistoryFolderPath = strInitialPath & "\历史采集" |
| If Not objFSO.FolderExists(strHistoryFolderPath) Then |
| objFSO.CreateFolder(strHistoryFolderPath) |
| End If |
| |
| |
| Set objCurrentFolder = objFSO.GetFolder(strInitialPath) |
| For Each objCurrentFile In objCurrentFolder.Files |
| If InStr(objCurrentFile.Name, "错题采集") > 0 And (LCase(objFSO.GetExtensionName(objCurrentFile.Name)) = "doc" Or LCase(objFSO.GetExtensionName(objCurrentFile.Name)) = "docx") Then |
| objCurrentFile.Move strHistoryFolderPath & "\" & objCurrentFile.Name |
| End If |
| Next |
| |
| |
| strFolderPath = "D:\123" |
| |
| |
| If Not objFSO.FolderExists(strFolderPath) Then |
| MsgBox "目录不存在!", vbExclamation, "错误" |
| WScript.Quit |
| End If |
| |
| |
| objDate = Now |
| strDate = Year(objDate) & Right("0" & Month(objDate), 2) & Right("0" & Day(objDate), 2) |
| strTime = Right("0" & Hour(objDate), 2) & Right("0" & Minute(objDate), 2) & Right("0" & Second(objDate), 2) |
| strDateTime = strDate & strTime |
| |
| |
| strInputNumber = InputBox("请输入当前试卷播种号:", "输入数值") |
| |
| |
| strDocName = strInitialPath & "\" & strDateTime & "错题采集_播种" & strInputNumber & ".docx" |
| |
| |
| Set objFolder = objFSO.GetFolder(strFolderPath) |
| |
| |
| Set objWord = CreateObject("Word.Application") |
| objWord.Visible = False |
| |
| |
| Set objDoc = objWord.Documents.Add |
| |
| |
| Set objPageSetup = objDoc.PageSetup |
| objPageSetup.Orientation = 0 |
| objPageSetup.TopMargin = objWord.CentimetersToPoints(2) |
| objPageSetup.BottomMargin = objWord.CentimetersToPoints(1) |
| objPageSetup.LeftMargin = objWord.CentimetersToPoints(1) |
| objPageSetup.RightMargin = objWord.CentimetersToPoints(1) |
| objPageSetup.HeaderDistance = objWord.CentimetersToPoints(1) |
| objPageSetup.FooterDistance = objWord.CentimetersToPoints(0.5) |
| |
| |
| |
| objPageSetup.PaperSize = 8 |
| |
| |
| Set objColumns = objDoc.Sections(1).PageSetup.TextColumns |
| objColumns.SetCount(2) |
| objColumns.LineBetween = True |
| |
| |
| With objDoc.Sections(1).Headers(1).Range |
| .ParagraphFormat.Alignment = 2 |
| .Font.Name = "宋体" |
| .Font.Size = 10.5 |
| .Text = "" |
| End With |
| |
| |
| For Each objFile In objFolder.Files |
| |
| strFileName = objFile.Name |
| |
| |
| If LCase(objFSO.GetExtensionName(strFileName)) = "jpg" Then |
| |
| objDoc.Content.InsertAfter objFSO.GetBaseName(strFileName) & vbCrLf |
| End If |
| Next |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| objWord.CommandBars("Navigation").Visible = False |
| |
| |
| objDoc.SaveAs strDocName |
| |
| |
| objDoc.Close |
| |
| |
| objWord.Quit |
| |
| |
| Set objDoc = Nothing |
| Set objWord = Nothing |
| Set objFolder = Nothing |
| Set objFSO = Nothing |
| Set objShell = Nothing |
| |
| |
| Set objWord = CreateObject("Word.Application") |
| objWord.Visible = True |
| objWord.Documents.Open strDocName |
| |
| Set objWord = NothingCOPY |