Dim oExcel As excel.Workbook
Set oExcel = Df1.ActiveDocument
Err.Clear
oExcel.Application.DisplayAlerts = False
oExcel.Application.Cells.Find(what:=strSName, LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False).Activate
If Err.Number = 0 Then
  oExcel.Application.ActiveSheet.Paste
End If
Clipboard.Clear
oExcel.Application.Quit
Set oExcel = Nothing

解决方案 »

  1.   

    oExcel.Application.DisplayAlerts = False 
    这一行出错
      

  2.   

        Dim xlApp as Excel.Application
        Dim xlBook as Excel.WorkBook
        Dim xlSheet as Excel.WorkSheet
        Set xlApp = CreateObject("Excel.Application")
        xlApp.Visible = True
        Set xlBook = xlApp.Workbooks.Open("xls_Path")  '指明Workbook的路径
        Set xlSheet = xlBook.Worksheets(1)
        xlSheet.Activate
        Err.Clear
        xlBook.Application.DisplayAlerts = False
    自己写了个程序用xlBook.Application.DisplayAlerts = False,没有出错。
    把变量都声明全了,指明Workbook的路径,就不会有错。
      

  3.   

    Df1.ActiveDocument 是什么?
      

  4.   

    Set xlBook = xlApp.Workbooks.Open("xls_Path")    这里  如果是相对路径 加上app.path
    绝对路径 自己的写路径