Word文書をpdfに変換して、作成したOutlook電子メールの一部として添付ファイルとして送信したいと思います。Word文書をpdfに変換してOutlookの添付ファイルとして送信
SaveAs2行の末尾に「.pdf」を追加しようとしましたが、これはファイル形式を変更してpdfとして添付しましたが、ファイルを開こうとすると表示されず、添付ファイルとして送信されたときにファイルにコードがすべて含まれていませんでした。
ご意見をいただければ幸いです。おかげ
Private Sub emailbutton_Click()
'No-option email sending
Dim OL As Object
Dim EmailItem As Object
Dim Doc As Document
Application.ScreenUpdating = False
Set OL = CreateObject("Outlook.Application")
Set EmailItem = OL.CreateItem(olMailItem)
Set Doc = ActiveDocument
If VName.Value = "" Then
Doc.SaveAs ("Quotation_Blank 2016")
Else
Doc.SaveAs2 ("QFORM" & "_" & JNumber.Value & "_" & VName.Value)
End If
With EmailItem
.Display
End With
' Signature = EmailItem.body
With EmailItem
.Subject = "QFORM" & "_" & JNumber.Value & "_" & VName.Value
'HTMLbody
msg = "<b><font face=""Times New Roman"" size=""4"" color=""blue"">INTEGRATED ASSEMBLY </font></b><br>" _
& " 1200 Woodruff Rd.<br>" _
& " Suite A12<br>" _
& " Greenville, SC 29607<br><br>" _
& "We have recently released subject project, which will contain assemblies to be outsourced. You have been selected to build these assemblies according to the attachment. <br><br>" _
& "As part of this process, please review the quotation form attached and indicate your acceptance. If adjustments and-or corrections are required, please feel free to contact us for quick resolution. <br><br>" _
& "<b><font face=""Times New Roman"" size=""4"" color=""Red"">NOTE: </font></b>" _
& "The information on attached quotation form is not a contract and only an estimate of predetermined costs per hourly rate for outsource assemblies. <br><br>" _
& "*******For your records you may wish to print out the completed quote form. <br><br>" _
& "Thank you, <br><br>" _
& "<b>HARTNESS INTERNATIONAL </b><br>" _
& "H1 Production Control <br>" _
& vbNewLine & Signature
.HTMLBody = msg & .HTMLBody
If VName.Value = "INTEGRATED ASSEMBLY" Then
.To = "Email1.com;"
.CC = "Email2.com;" & "Email3.com;"
.Importance = olImportanceNormal 'Or olImportanceHigh Or olImportanceLow
.Attachments.Add Doc.FullName
.Display
ElseIf VName.Value = "LEWALLEN" Then
.To = "Email1.com;"
.CC = "Email2.com;" & "Email3.com;"
.Importance = olImportanceNormal 'Or olImportanceHigh Or olImportanceLow
.Attachments.Add Doc.FullName
.Display
End If
End With
Application.ScreenUpdating = True
Set Doc = Nothing
Set OL = Nothing
Set EmailItem = Nothing
End Sub
コードは私の必要なもののように見えますが、現在のフォルダに保存するパスを作成する方法と、このコードの添付ファイルとして追加する方法については別の問題だと思います。私は現在、.Attachment.Add Doc.FullNameを使用していますが、pdfの代わりにwordファイルを引き出しています。 –
@ReyTaino更新された応答を参照してください – 0m3r
良いコール@ Om3r - パスをConstにするだけでそれを微調整しなければなりませんでした。 "コンパイルエラー - 現在のパスで読み取り専用プロパティに割り当てることができません" 。ご協力ありがとうございました。 –