저는 열 필요가있는 약 .msg, outlook 파일이 있으며, Excel 첨부 파일을 .csv 파일로 변환하고 저장하지 않아도됩니다. 현재 아래의 코드는 .msg outlook 파일을 열면 오류가 나타납니다. .msg 파일을 열 수 없습니다.
.msg 파일을 열려면 어떻게합니까?
스크립트 :
Sub OpenMSGRenameDownloadAttachement()
Dim objOL As Outlook.Application
Dim Msg As Outlook.MailItem
Dim MsgCount As Integer
Set objOL = CreateObject("Outlook.Application")
'Change the path given month, ie. do this for Jan, Feb, April
inPath = "C:\January Messages"
thisFile = LCase(Dir(inPath & "\*.msg"))
Do While thisFile <> ""
Set Msg = objOL.Session.OpenSharedItem(thisFile)
Msg.Display
MsgBox Msg.Subject
thisFile = Dir
Loop
Set objOL = Nothing
Set Msg = Nothing
End Sub
나는 이것이 명백한 질문이지만, 파일이 이미 열려있는 것 같아요? 예 : Outlook에서? 또는 Excel에서 이전 코드 시도가 실패한 경우? 또는 이전에 성공적으로 시도한 Excel에서? (명시 적으로'Close'를하고있는 것처럼 보이지 않으므로 여전히 열려있을 수 있습니다.) 또한이 페이지가 적용됩니까? https://support.microsoft.com/en-us/help/2633737/the -openshareditem-method-for-outlook-hold-a-file-on-signed-.msg-files – YowE3K
이것은 한 번 할 일입니다. 적어도 전자 메일을 열려면이 코드를 다시 작성해야합니다. 거기에서 Excel 코드를 변환 할 수는 있습니다. – Sauron
Dir을 잘못 사용하고 있습니다. 'thisFile = Dir (inPath)'와'Do While thisFile <> ' "'''If (IfFile, 3) ="msg "Then'이면 If 조건을 넣고 실제로 메시지를 열 필요는 없습니다. 내가 아는 한 첨부 파일을 얻으십시오. – Tehscript