5,139
社区成员
发帖
与我相关
我的任务
分享
Sub CommandButton1_Click()
Dim ft(1 To 25) As String
Dim fc As Integer
Dim i As Integer
Dim r As Integer
Dim wbbook As Workbook
Dim wbSheet As Worksheet
r = ActiveCell.Row
Dim FN As String, In_Count As Long
Dim wddoc, wdapp
Set wdapp = CreateObject("Word.Application")
wdapp.Visible = False
wdapp.DisplayAlerts = wdAlertsNone
FN = Dir(ThisWorkbook.Path & "\*.doc")
Do Until FN = ""
FN = ThisWorkbook.Path & "\" & FN
Set wddoc = wdapp.Documents.Open(FN)
With wddoc
fc = wddoc.FormFields.Count ’这里无法获得word控件的数量
For i = l To fc
ft(i) = wddoc.FormFields(i).Result ‘这里无法获得word控件的内容
Next i
End With
With wbSheet
For i = l To fc
Cells(r, i) = ft(i)
Next i
r = r + 1
End With
In_Count = In_Count + 1
wddoc.Close False
FN = Dir()
Loop
wdapp.Quit
Set wddoc = Nothing
Set wdapp = Nothing
End Sub