Excel 365 Email Code

Luke Chappel

New Member
Joined
Jun 5, 2013
Messages
1
Hi Guys,

Is anyone able to help with my code? I have moved to Office 365 and my email code now changes the subject line to random characters. For example 獹䰥렀绽ঈE折[꛰ˏ&

Currently it is as follows and works well with 2010 and 2013.
Code:
Sub EmailReport()


Application.ScreenUpdating = False
Application.DisplayAlerts = False




    Dim Recip()
        ReDim Preserve Recip(0)
        Recip(0) = "blabla@blabla.com"


        ReDim Preserve Recip(1)
        Recip(1) = "blablabla@blabla.com"

 Dim TempFilePath As String
TempFilePath = Application.DefaultFilePath
'MsgBox "You can find the new file in " & TempFilePath


ActiveWorkbook.SaveCopyAs TempFilePath & "\Phys Pos HardCode " & Format(Date, "dd_mm_yyyy") & ".xlsm"
        
    Workbooks.Open (TempFilePath & "\Phys Pos HardCode " & Format(Date, "dd_mm_yyyy") & ".xlsm")
    Sheets.Select
    Cells.Select
    Selection.Copy
    Cells.Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False


    Sheets("Controls").Select
    ActiveWindow.SelectedSheets.Delete
    Sheets("ZSTAT").Select
    ActiveWindow.SelectedSheets.Delete


    ActiveWorkbook.Save


With ActiveWorkbook
    .SendMail Recipients:=Recip, Subject:="Position Report " & Format(Date, "dd/mmm/yyyy")
    .Close SaveChanges:=False
End With
    
Kill TempFilePath & "\Phys Pos HardCode " & Format(Date, "dd_mm_yyyy") & ".xlsm"
  
Application.Goto Reference:=Sheets("Controls").Range("A1")


Application.ScreenUpdating = True
Application.DisplayAlerts = True


End Sub
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

Forum statistics

Threads
1,215,836
Messages
6,127,180
Members
449,368
Latest member
JayHo

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