Hi,
I have a word document to which few cells are linked from an excel sheet. what I am trying to do is send this word document in email as pdf attachment. The challenge is I want the file name to be the text that is being pulled from excel sheet. Following is the code I am using to email the document.
Sub Saveandemail()
Dim OL As Object
Dim EmailItem As Object
Dim Doc As Document
Dim strFileName As String
Application.ScreenUpdating = False
Set OL = CreateObject("Outlook.Application")
Set EmailItem = OL.CreateItem(olMailItem)
Set Doc = ActiveDocument
strFileName = Replace(Doc.FullName, ".docm", ".pdf")
Doc.ExportAsFixedFormat OutputFileName:=strFileName, _
ExportFormat:=wdExportFormatPDF
With EmailItem
.Subject = ""
.Body = ""
.To = ""
.Attachments.Add strFileName
.Send
End With
Application.ScreenUpdating = True
Set Doc = Nothing
Set EmailItem = Nothing
Set OL = Nothing
End Sub
Can you please help me how to get the filename to be the cell value that is linked to excel sheet.
Bookmarks