毕业论文开发语言企业开发JAVA技术.NET技术WEB开发Linux/Unix数据库技术Windows平台移动平台嵌入式论文范文英语论文
您现在的位置: 毕业论文 >> 开发语言 >> 正文

vba获取word中控件的内容和个数代码

更新时间:2016-6-13:  来源:毕业论文

现在想在excel中编写vba 获取word中控件的内容和个数 代码感觉没问题,为什么不能获取呢
 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   

设为首页 | 联系站长 | 友情链接 | 网站地图 |

copyright©youerw.com 优尔论文网 严禁转载
如果本毕业论文网损害了您的利益或者侵犯了您的权利,请及时联系,我们一定会及时改正。