0
メールから添付ファイルからpdf docを開くことができます。今私はその内容をコピーしたいと思います。親切にすべてを選択してコピーするコードを提供してください。以下はコードですが、私はどこに助けが必要かを言及しました。 メールから添付ファイルからpdf docを開くことができます。今私はその内容をコピーしたいと思います。親切にすべてを選択してコピーするコードを提供してください。以下はコードですが、私はどこに助けが必要かを言及しました。PDFファイルからデータをコピーできません
Sub ExtractFirstUnreadEmailDetails()
Dim oOlAp As Object, oOlns As Object, oOlInb As Object
Dim oOlItm As Object
Dim objAtt As Outlook.Attachment
'On Error Resume Next
'~~> Outlook Variables for email
Dim eSender As String, dtRecvd As String, dtSent As String
Dim sSubj As String, sMsg As String
Dim AttchType As String
'~~> Get Outlook instance
Set oOlAp = GetObject(, "Outlook.application")
Set oOlns = oOlAp.GetNamespace("MAPI")
Set oOlInb = oOlns.GetDefaultFolder(olFolderInbox)
'~~> Check if there are any actual unread emails 'apurv
'If oOlInb.Items.Restrict("[UnRead] = True").Count = 0 Then 'apurv
' MsgBox "NO Unread Email In Inbox" 'apurv
' Exit Sub 'apurv
' End If 'apurv
'~~> Store the relevant info in the variables
'For Each oOlItm In oOlInb.Items.Restrict("[UnRead] = True")
For Each oOlItm In oOlInb.Items
eSender = oOlItm.SenderEmailAddress
dtRecvd = oOlItm.ReceivedTime
dtSent = oOlItm.CreationTime
sSubj = oOlItm.Subject
sMsg = oOlItm.Body
ToAddress = oOlItm.To
i = ThisWorkbook.ActiveSheet.Cells(Rows.Count, 2).End(xlUp).Row
Range("c" & (i + 1)).Value = eSender
Range("B" & (i + 1)).Value = dtRecvd
'range("c"&(i+1)).Value=dtSent
Range("E" & (i + 1)).Value = sSubj
Range("F" & (i + 1)).Value = sMsg
Range("D" & (i + 1)).Value = ToAddress
If oOlItm.Attachments.Count <> 0 Then
temp = ""
For Each oOlAtch In oOlItm.Attachments
temp = temp & "//" & oOlAtch.Filename
Next
Range("G" & (i + 1)).Value = temp
End If
If oOlItm.Attachments.Count <> 0 Then
temp = ""
For Each oOlAtch In oOlItm.Attachments
If InStr(1, UCase(oOlAtch.Filename), "PDF", vbTextCompare) > 1 Then
oOlAtch.SaveAsFile "D:\Users\apawar\Desktop\Attachments\" & oOlAtch.Filename
Shell "Explorer.exe /e,D:\Users\apawar\Desktop\Attachments\" & oOlAtch.Filename, vbNormalFocus
'NEED HELP HERE......Need to copy all data from pdf doc from 1st page
End If
Next
Range("G" & (i + 1)).Value = temp
End If
Next
MsgBox ("Down loaded successufully")
End Sub
をご覧ください。https://stackoverflow.com/a/37287583/7889129 – Maddy