problem with office 2010 sending mail

I have recently installed Office 2010 and now have a problem with the following code. It freezes on :

 Set OutApp = CreateObject("Outlook.Application")

I have checked that the 14.0 Object Library boxes are ticked in both Outlook and Excel references.

Thanks,
CC

Here is the code:
Option Explicit
Public Const TEMP_PIC_NAME = "EmailTemp.png" 'change extension to change picture type
Sub PositionMail()
' Don't forget to copy the function RangetoHTML in the module.
' Working in Office 2000-2010
    Dim rng As Range
    Dim OutApp As Object
    Dim OutMail As Object

    Set rng = Nothing
    On Error Resume Next
    'Only the visible cells in the selection
    'Set rng = Selection.SpecialCells(xlCellTypeVisible)
    'You can also use a range if you want
    'Set rng = Sheets("Position").Range("A1:Q36").SpecialCells(xlCellTypeVisible)
    Set rng = Sheets("Position").Range("A1:v36")
    On Error GoTo 0

    If rng Is Nothing Then
        MsgBox "The selection is not a range or the sheet is protected" & _
               vbNewLine & "please correct and try again.", vbOKOnly
        Exit Sub
    End If


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

    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)

    'On Error Resume Next
    With OutMail
        .To = "xxxx"
        .CC = "xxxx"
        .BCC = ""
        .Subject = "PositionSheet" & " " & Date
        .HTMLBody = RangetoHTML2(rng)
        .display        'Send   'or use .Display
        .Send
    End With
    On Error GoTo 0

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

    Set OutMail = Nothing
    Set OutApp = Nothing
 
    'ActiveWorkbook.Close True
End Sub
'Following CopyRangeToGIF and RangetoHTML2 routines Source:  Adapted from: http://www.jpsoftwaretech.com/excel-vba/send-email-from-excel/
Sub CopyRangeToGIF(rng As Range) ' save a range from Excel as a picture
'Dim rng As Excel.Range
Dim cht As Excel.ChartObject
Dim imgSrc As String

    imgSrc = ThisWorkbook.Path & "\" & TEMP_PIC_NAME
    Application.ScreenUpdating = False
    'Set rng = Range("A1").CurrentRegion
    rng.CopyPicture xlScreen, xlPicture
    Set cht = ActiveSheet.ChartObjects.Add(0, 0, rng.Width + 10, rng.Height + 10)
    cht.Chart.Paste
    cht.Chart.Export imgSrc
    cht.Delete
ExitProc:
    Application.ScreenUpdating = True
    Set cht = Nothing
    Set rng = Nothing

End Sub
Function RangetoHTML2(rng As Range)
Dim imgSrc As String

    Call CopyRangeToGIF(rng)
    imgSrc = ThisWorkbook.Path & "\" & TEMP_PIC_NAME
    RangetoHTML2 = "<body><font face=Arial color=#000080 size=2></font>" & _
        "<img alt='' hspace=0 src='" & imgSrc & "' align=baseline 0rder=0>&nbsp;" & _
        "<br /><br />No Trading on a Friday or for 24hours after a stop. No averaging of positions. If the intramonth loss exceeds 1%, max exposure of the portfolio cannot exceed 50%</body>"
End Function
Function RangetoHTML(rng As Range)
' Changed by Ron de Bruin 28-Oct-2006
' Working in Office 2000-2010
    Dim fso As Object
    Dim ts As Object
    Dim TempFile As String
    Dim TempWB As Workbook

    TempFile = Environ$("temp") & "\" & Format(Now, "dd-mm-yy h-mm-ss") & ".htm"

    'Copy the range and create a new workbook to past the data in
    rng.Copy
    Set TempWB = Workbooks.Add(1)
    With TempWB.Sheets(1)
        .Cells(1).PasteSpecial Paste:=8
        .Cells(1).PasteSpecial xlPasteValues, , False, False
        .Cells(1).PasteSpecial xlPasteFormats, , False, False
        .Cells(1).Select
        Application.CutCopyMode = False
        On Error Resume Next
        .DrawingObjects.Visible = True
        .DrawingObjects.Delete
        On Error GoTo 0
    End With

    'Publish the sheet to a htm file
    With TempWB.PublishObjects.Add( _
         SourceType:=xlSourceRange, _
         Filename:=TempFile, _
         Sheet:=TempWB.Sheets(1).Name, _
         Source:=TempWB.Sheets(1).UsedRange.Address, _
         HtmlType:=xlHtmlStatic)
        .Publish (True)
       
    End With

    'Read all data from the htm file into RangetoHTML
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set ts = fso.GetFile(TempFile).OpenAsTextStream(1, -2)
    RangetoHTML = ts.ReadAll
    ts.Close
    RangetoHTML = Replace(RangetoHTML, "align=center x:publishsource=", _
                          "align=left x:publishsource=")

    'Close TempWB
    TempWB.Close savechanges:=False

    'Delete the htm file we used in this function
    Kill TempFile

    Set ts = Nothing
    Set fso = Nothing
    Set TempWB = Nothing
End Function
CC10Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

terencinoCommented:
Well your code works just fine for me, in Excel 2010. I didn't have to tick any other references, these were ticked as shown attached.ReferencesAre you using the 32-bit version of Office or the 64-bit version
...Terry
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CC10Author Commented:
I uninstalled the 64 bit and installed the 32-bit version and now it works again. Thanks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Applications

From novice to tech pro — start learning today.