错误9在不同的路径中激活工作簿

时间:2016-01-25 17:03:49

标签: excel vba

当我尝试在特定路径中的工作簿中选择数据时,我收到错误9。

这是我的代码:

   myPath = "Z:\7. Personnel\Florian\Projet_BDC\Test\"
   myPath2 = "Z:\7. Personnel\Florian\Projet_BDC\Test\Consolidations\"
   Set sht = Workbooks("Consolidation.xlsm").Worksheets(2)

Set wbconso_dest = Workbooks.Add
    wbconso_dest.SaveAs Filename:=myPath2 & "Consolidation." & Dateconso & ".xlsx"
    Workbooks(myPath & "Consolidation.xlsm").Activate
    sht.Range("A1").Select
    Range(Selection, Selection.End(xlToRight)).Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.Copy Destination:=wbconso_dest.Worksheets(1)
    wbconso.Close

在这一行我收到错误:

 Workbooks(myPath & "Consolidation.xlsm").Activate

0 个答案:

没有答案