两件事情
- 将路径声明为字符串而不是范围。
- 在路径中使用之前替换日期中的“\”
这是你正在尝试的吗?
Dim path As String
path = shPivot.Range("E12").Value
Set wkbFrom = Workbooks.Open("S:\_Supply Chain\Weekly Rpts Supplier and Buyer\" & _
format(path,"DD-MM-YYYY") & _
"\SUPPLIER_01_00028257_KIK CUSTOM PRODUCTS GAINSVILLE_21-OCT-12.xls")
跟进
在这种情况下使用这个
Dim path As String
path = shPivot.Range("E12").Value
Set wkbFrom = Workbooks.Open("S:\_Supply Chain\Weekly Rpts Supplier and Buyer\" & _
path & _
"\SUPPLIER_01_00028257_KIK CUSTOM PRODUCTS GAINSVILLE_21-OCT-12.xls")
如果有任何不需要的空格,那么您将不得不使用TRIM
Dim path As String
path = shPivot.Range("E12").Value
Set wkbFrom = Workbooks.Open("S:\_Supply Chain\Weekly Rpts Supplier and Buyer\" & _
Trim(path) & _
"\SUPPLIER_01_00028257_KIK CUSTOM PRODUCTS GAINSVILLE_21-OCT-12.xls")