현재 통합 문서와 같은 디렉터리 file
에있는 폴더 ( Source
)에 저장된 파일 ( ) 을 열고 싶습니다 . 파일을 찾을 수 없음을 나타내는 런타임 오류 1004가 표시됩니다. 나는 wearg 무엇을하고 있는가?
Set x = Workbooks.Open(ThisWorkbook.Path & "\Source\file*.xlsx")
와일드 카드를 유지하려면 폴더에있는 파일을 반복해야합니다. 다음과 같은 내용이 흥미로울 수 있습니다.
Sub FileOpen()
Dim sPath As String
Dim sFile As String
Dim wb As Workbook
sPath = ThisWorkbook.Path & "\Source\"
sFile = Dir(sPath & "file*.xlsx")
' Loops while there is a next file found in the specified directory
' When there is no next file the Dir() returns an empty string ""
Do While sFile <> ""
' Prints the full path of the found file
Debug.Print sPath & sFile
' Opens the currently found file
Set wb = Workbooks.Open(sPath & sFile)
' Place your code here
' Place your code here
' Place your code here
' Close the current workbook and move on to the next
wb.Close
' This line calls the Dir() function again to get the next file
sFile = Dir()
Loop
End Sub
행운을 빕니다!
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다