1
활성 단어 문서의 정확한 경로를 가져 오려고합니다. 아래 코드를 작성했습니다. 한 단어 문서가 열려 있으면 코드가 제대로 작동하지만 두 번째 문서를 열고 실행하면 경로가 "내 문서"로 표시됩니다. 첫 번째 문서에서도, 지금 실행하면 "내 문서"가 표시됩니다. 코드는 다음과 같습니다.VBScript에서 잘못된 경로 이름 가져 오기
Sub NewMenuMacro()
Dim myMenuItem As Object
Dim objIE As Object
Dim folderName
folderName = "..\.."
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
Dim fullpath
fullpath = fso.GetAbsolutePathName(Me.Application.ActiveDocument)
If fso.FileExists(fullpath) Then
Dim objFile
' fullpath = fso.GetAbsolutePathName(Me.Application.ActiveDocument)
Set objFile = fso.GetFile(fullpath)
ActiveDocument.SaveAs (objFile.path)
fullpath = fso.GetAbsolutePathName(objFile)
Else
ActiveDocument.Save
fullpath = fso.GetAbsolutePathName(Me.Application.ActiveDocument)
End If