|
Private Sub CommandButton1_Click()
Dim WordApp As Object, Doc_Active, fname$, LastRow
Application.ScreenUpdating = False
Set WordApp = CreateObject("Word.Application")
WordApp.Visible = False
WordApp.DisplayAlerts = 0
On Error Resume Next
fname = Dir(ThisWorkbook.Path & "\" & "*.doc*")
Do Until fname = ""
If Not IsError(Application.Match(fname, Sheet1.Columns(11), 0)) Then GoTo LineNext
LastRow = Sheet1.Cells(Sheet1.Cells.Rows.Count, 1).End(xlUp).Row + 1
Set Doc_Active = WordApp.Documents.Open(ThisWorkbook.Path & "\" & fname, , True)
With Doc_Active
Sheet1.Cells(LastRow, 1) = Split(Split(.Range, "工单转办表")(1), Chr(13))(0)
Sheet1.Cells(LastRow, 2) = Trim(Split(Split(Split(.Range, "事件单位")(1), Chr(13))(1), Chr(7))(1))
Sheet1.Cells(LastRow, 4) = Trim(Split(Split(Split(.Range, "来电时间")(1), Chr(13))(1), Chr(7))(1))
Sheet1.Cells(LastRow, 5) = Trim(Split(Split(Split(.Range, "工单流水号")(1), Chr(13))(1), Chr(7))(1))
Sheet1.Cells(LastRow, 6) = Trim(Split(Split(Split(.Range, "事件主题")(1), Chr(13))(1), Chr(7))(1))
Sheet1.Cells(LastRow, 7) = Trim(Split(Split(Split(.Range, "呼叫电话")(1), Chr(13))(1), Chr(7))(1))
Sheet1.Cells(LastRow, 8) = Trim(Split(Split(Split(.Range, "来电人姓名")(1), Chr(13))(1), Chr(7))(1))
Sheet1.Cells(LastRow, 9) = Trim(Split(Split(Split(.Range, "工单内容")(1), Chr(13))(1), Chr(7))(1))
Sheet1.Cells(LastRow, 10) = Trim(Split(Split(Split(.Range, "到期时间")(1), Chr(13))(1), Chr(7))(1))
Sheet1.Cells(LastRow, 11) = fname
End With
Doc_Active.Close
LineNext:
fname = Dir
Loop
WordApp.Quit
Set WordApp = Nothing
Application.ScreenUpdating = True
End Sub
|
评分
-
1
查看全部评分
-
|