使用Microsoft Excel 2010; Visual Basic for Applications(VBA)運行時錯誤'1004':對象'工作簿'的方法'打開'失敗
嘗試編寫過程以打開工作簿並將電子表格從一個工作簿複製到活動工作簿。
運行時error'1004' :方法‘工作簿‘’對象’打開失敗
下面是代碼我使用:
'Declares variables
Dim ToBook As Workbook
Dim FromBook As String
Dim FromSheet As Worksheet
Dim diaTitle As String
Dim FilterName As String
'-----------------------------------------------------------------------------------------------
Set ToBook = ActiveWorkbook
diaTitle = "Select Systems List"
FromBook = Application.GetOpenFilename(_
FileFilter:=FilterName, _
FilterIndex:=2, _
Title:=diaTitle)
If FromBook = "False" Then
Exit Sub
End If
Workbooks.Open _
Filename:=FromBook, _
UpdateLinks:=xlUpdateLinksNever, _
ReadOnly:=False, _
Format:=5, _
Password:="", _
WriteResPassword:="", _
IgnoreReadOnlyRecommended:="", _
Origin:="", _
Delimiter:="", _
Editable:="", _
Notify:="", _
Converter:="", _
AddToMru:="", _
Local:="", _
CorruptLoad:=xlNormalLoad
Set FromSheet = Workbooks(FromBook).Worksheets("Sheet1")
'-----------------------------------------------------------------------------------------------
FromSheet.Copy _
After:=ToBook.Worksheets(6)
Workbooks(FromBook).Close _
SaveChanges:=False, _
Filename:=FromBook, _
RouteWorkbook:=""
什麼線路上的錯誤? – KyloRen
Workbook上發生錯誤。打開行 – TroyPilewski
什麼是FromBook在開放行? –