Dao Ha Quang
New Member
- Joined
- Apr 30, 2023
- Messages
- 20
- Office Version
- 2016
HelloSub CopySheet()
FileName = Application.GetOpenFilename("Excel Files (*.xls;*.xlsx;*.xlsm),*.xls;*.xlsx;*.xlsm", Title:="OPEN FILE", MultiSelect:=False)
Set closedBook = Workbooks.Open(FileName)
closedBook.Sheets("Sheets1").Move Before:=ThisWorkbook.Sheets("Sheets2")
closedBook.Close SaveChanges:=False
If FileName = False Then Exit Sub
End Sub
I use this VBA to select open excel file then Copy "Sheets1" to current excel file.
But there is a problem that if the opened excel file is in a folder with name have special character, it will get the error "Path error / file access error: '.\VBxxx.tmp"
I have the idea to copy the File containing "Sheets1" to the Desktop, then copy "Sheets1" to the current excel file, then delete the file on the Desktop. But I don't know how to do that. Help me