Hi Folks

I have some code which I've used very successfully for several years (on excel 2003 & 2007 )which makes temp excel files of all relevant sheets and emails each of them separately )

I now need to use this same code in a different workbook, but this time convert them into PDF files. I'm using Excel 2010 and Windows 7

Sub Mail_Every_Worksheet_Customer()

'Working in 2000-2007
'Application.Run "'Charges Summary_V10.xls'!Macro1"
Dim sh As Worksheet
Dim wb As Workbook
Dim FileExtStr As String
Dim FileFormatNum As Long
Dim TempFilePath As String
Dim TempFileName As String
Dim OutApp As Object
Dim OutMail As Object

TempFilePath = Environ$("temp") & "\"

If Val(Application.Version) < 12 Then
'You use Excel 97-2003
FileExtStr = ".xls": FileFormatNum = -4143
Else
'You use Excel 2007
' FileExtStr = ".xlsm": FileFormatNum = 52

FileExtStr = ".pdf": FileFormatNum = 17

End If

With Application
.ScreenUpdating = False
.EnableEvents = False
End With

Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon

For Each sh In ThisWorkbook.Worksheets
If sh.Range("f1").Value Like "?*@?*.?*" Then

sh.Copy
Set wb = ActiveWorkbook

TempFileName = "Customer " & sh.Range("c2") & "Purchase Order " & sh.Range("d2")

Set OutMail = OutApp.CreateItem(0)

With wb
.SaveAs TempFilePath & TempFileName & FileExtStr, FileFormat:=FileFormatNum


On Error Resume Next
With OutMail
.to = sh.Range("b1").Value
.CC = ""
.BCC = ""
.Subject = "F20 File " & " " & TempFileName


.body = "Dear All ," & vbNewLine & vbNewLine & " Please find attached a breakdown for your movements completed for week" & " " & Evaluate("WEEKNUM(now()-14)") & " " & vbNewLine & vbNewLine & " Please validate/confirm the data, responding to this email with either 'Confirmed' or 'Query' (providing details) to your contact before Wednesday 17:00hrs." & vbNewLine & vbNewLine & " Failure to confirm by this date could result in delayed payment of your weekly charges " & vbNewLine & vbNewLine & "Kind Regards," & vbNewLine & vbNewLine & " Distribution Support" & vbNewLine & vbNewLine

.Attachments.Add wb.FullName
'You can add other files also like this
'.Attachments.Add ("C:\test.txt")
.display
End With
On Error GoTo 0

.Close savechanges:=False
End With
Set OutMail = Nothing

Kill TempFilePath & TempFileName & FileExtStr & FileFormatNum


End If
Next sh

Set OutApp = Nothing

With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub


I've tried a number of different ways of creating the PDF but nothing seems to work. The one i have used above:

FileExtStr = ".PDF": FileFormatNum = 17

When i try and open the file up from outlook, i get the following error

Adobe reader could not open........because it is either not a supported file type or because the file has been damaged (for example it was sent as an email attachment and wasn't correctly decoded)