1
특정 워크 시트의 모든 정보를 복사하여 새 통합 문서로 복사하는 Excel 매크로가 있습니다. 코드는 다음과 같습니다.Excel 매크로 : 올바른 디렉터리에 저장하지 않는 이유는 무엇입니까?
Option Explicit
Sub TwoSheetsAndYourOut()
Dim NewName As String
Dim nm As Name
Dim ws As Worksheet
If MsgBox("Copy specific sheets to a new workbook" & vbCr & _
"New sheets will be pasted as values, named ranges removed" _
, vbYesNo, "New Copy") = vbNo Then Exit Sub
With Application
.ScreenUpdating = False
On Error GoTo ErrCatcher
Sheets("Input").Copy
On Error GoTo 0
For Each ws In ActiveWorkbook.Worksheets
ws.Cells.Copy
ws.[A1].PasteSpecial Paste:=xlValues
ws.Cells.Hyperlinks.Delete
Application.CutCopyMode = False
Cells(1, 1).Select
ws.Activate
Next ws
Cells(1, 1).Select
For Each nm In ActiveWorkbook.Names
nm.Delete
Next nm
NewName = InputBox("Please specify the name of your new workbook", "New Copy", "input")
Dim sPath As String
sPath = ThisWorkbook.Path
ActiveWorkbook.SaveCopyAs sPath & NewName + ".xls"
ActiveWorkbook.Close SaveChanges:=False
.ScreenUpdating = True
End With
Exit Sub
ErrCatcher:
MsgBox "Specified sheets do not exist within this workbook"
End Sub
그러나 올바른 Excel 파일은 올바른 디렉터리에 저장되지 않습니다. 원래 Excel 파일, 매크로를 포함 하나, (Mac에서) 다음 디렉토리에 있습니다
이/응용 프로그램/워드 넷 /가
그러나 프로젝트, 내가 매크로를 실행할 때마다, 그것은 새로운 저장 프로젝트 폴더 대신 WORDNET 폴더의 Excel 파일.
코드를 수정하여 올바른 위치에 저장하려면 어떻게해야합니까? 왜 원래 Excel 파일과 동일한 디렉토리에 저장되지 않습니까?