@joopw, thank you very much for directing me to Ron de Bruin's website. I have been able to customize the code in his original file and make that work; however when I try to replicate the exact same code in one (1) of my files I am getting the following error:
"Outlook does not recognize one or more names."
The code I am using is as follows:
'Derived from Ron de Bruin's original code. Please visit Ron de Bruin's website at Ron de Bruin Excel Automation for the original source code.
Code:
Sub SendFeedbackForm()
Dim FileName As String
Dim FixedFilePathName As String
Dim OutApp As Object
Dim OutMail As Object
Dim sTo As String
Dim sCC As String
Dim sBCC As String
Dim sSubject As String
Dim sBody As String
FixedFilePathName = "C:\Documents and Settings\" & fOSUserName() & "\Desktop\" & WorksheetFunction.VLookup(fOSUserName(), Worksheets("sheet1").Range("a1:c1"), 2, False) & ".pdf"
If ActiveWindow.SelectedSheets.Count > 1 Then
MsgBox "There is more then one sheet selected," & vbNewLine & _
"be aware that every selected sheet will be published"
End If
'Ron de Bruin's original code modified.
FileName = CreateFeedbackFormPDF(ActiveSheet, FixedFilePathName, True, False)
If FileName <> "" Then
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
sTo = "zyousafi@test.com"
sCC = "zyousafi@test.com" & "zyousafi@test.com" & ";"
sBCC = ""
sSubject = "Test"
sBody = "Test" & vbNewLine & vbNewLine & _
"Regards," & vbNewLine & vbNewLine & "Zohair Yousafi"
With OutMail
.To = sTo
.CC = sCC
.BCC = sBCC
.Subject = sSubject
.body = sBody
.Attachments.Add FixedFilePathName
.send
End With
Set OutMail = Nothing
Set OutApp = Nothing
Else
MsgBox "An error has occurred. Please contact your system administrator."
End If
'Delete the file from the user's desktop.
Kill FixedFilePathName
End Sub
Please help
Bookmarks