升级到2007 VBA后无法保存文件

时间:2013-05-09 10:24:34

标签: excel vba excel-vba access-vba

我有一个sub,我打电话来保存文件

Sub SaveToFile()

    maxr = Worksheets("List").Range("H1")

    Worksheets("List").Range("G1:AE" & maxr).Copy

升级到2007之后失败的部分代码是:

    With Application.FileSearch
        .LookIn = "Q:\Planning Tools\Reports\"
        .Filename = "Plan_" & ThisSaveTime & ".xls"

我收到运行时错误'445'对象不支持此操作,代码接下来继续:

        If .Execute > 0 Then 'Existing Workbook
            Application.Workbooks.Open ("Q:\Planning Tools\Reports\Plan_" & ThisSaveTime & ".xls")
            ActiveWorkbook.Worksheets.Add
            ActiveWorkbook.Sheets("Sheet1").Select
            ActiveWorkbook.Sheets("Sheet1").Name = ThisPlanSaveName
        Else 'No existing Workbook, so add one
            Workbooks.Add 1
            ActiveWorkbook.Sheets("Sheet1").Select
            ActiveWorkbook.Sheets("Sheet1").Name = ThisPlanSaveName
        End If
   End With

    ......

End Sub

我不确定哪个动作失败但有人能看出原因吗?

由于

1 个答案:

答案 0 :(得分:3)