VBA code failing in older versions

gordsky

Well-known Member
Joined
Jun 2, 2016
Messages
556
Office Version
  1. 2016
Platform
  1. Windows
Hi All,

I use the below code without issue on the machines at work to generate emails from vba and paste various bits from spreadsheets into them. All but two of the machines are using Excel/Outlook 2016 or later and the code runs no problem on them

2 of the machines were swapped out and replaced with ones running 2013 versions of both and the code now fails on the line " signature = newEmail.htmlBody"
Can anybody tell me why or point me in the direction of a solution

VBA Code:
Dim Outlook As Object, newEmail As Object
Dim signature As String

Set Outlook = CreateObject("Outlook.Application")
Set newEmail = Outlook.CreateItem(0)
Who = 'takes names from the spreadsheet


Set newEmail = Outlook.CreateItem(0)
                
            With newEmail
              
              .display
               signature = newEmail.htmlBody
              .To = Who
              
              .subject = ThisWorkbook.Name
              .ReadReceiptRequested = False
                        
               Application.CutCopyMode = False
              .Attachments.Add ThisWorkbook.FullName
    
            End With
End Sub
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
would this also explain why pasting to the email from PageEditor has stopped working as well?
 
Upvote 0

Forum statistics

Threads
1,214,915
Messages
6,122,214
Members
449,074
Latest member
cancansova

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top