Email Sheet-Must always be on Cell A

howard

Well-known Member
Joined
Jun 26, 2006
Messages
6,561
Office Version
  1. 2021
Platform
  1. Windows
I have the following code below to attach a sheet from Excel in Outlook

I would like the code mended so that when the attachment is opened, it will be on Cell A1

Your assistance is most appreciated

Code:
Sub Email_BR1()

Dim File As String, strBody As String

Application.ScreenUpdating = False

Application.DisplayAlerts = False

File = Environ$("temp") & "\" & Format(Range("Q2"), "mmm-yy ") & Format(Now, "dd-mmm-yy h-mm-ss") & ".xlsx"

strBody = "Hi " & Sheets("BR1").Range("S2") & vbNewLine & vbNewLine & _

"Attached, please find current " & Sheets("BR1").Range("Q3") & vbNewLine & vbNewLine & _

"Regards" & vbNewLine & vbNewLine & _

"Howard"
ActiveWorkbook.Save

Sheets("BR1").Copy

With ActiveWorkbook

.SaveAs Filename:=File, FileFormat:=51

.Close savechanges:=False

Range("A1").Select



End With

With CreateObject("Outlook.Application").CreateItem(0)

.Display

.to = Join(Application.Transpose(Sheets("BR1").Range("R2:R5").Value), ";")

.Subject = Sheets("BR1").Range("Q3")

.body = strBody

.Attachments.Add File

End With

Kill File

Application.ScreenUpdating = True

Application.DisplayAlerts = True

End Sub
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
change order and add dot before range:

VBA Code:
With ActiveWorkbook
    .Range("A1").Select
    .SaveAs Filename:=File, FileFormat:=51
    .Close savechanges:=False
End With
 
Upvote 0
Thanks for the help

I now get a run time error

"Object doesn't support this property or method"

Code:
 With ActiveWorkbook
  .Range("A1").Select

    
    .SaveAs Filename:=File, FileFormat:=51
    .Close savechanges:=False
End With

The part below is in yellow when debugging it

Code:
   .Range("A1").Select

Kindly test & advise on how to resolve this
 
Upvote 0
change:
.Range("A1").Select
to
ActiveSheet.Range("A1").Select
or try without dot, but with new order.
 
Upvote 0
Thanks for the help

It still did not select A1 in the activesheet

I added these two ines of code beneath it and it now works


Code:
 ActiveWindow.ScrollRow = 1
   ActiveWindow.ScrollColumn = 1
 
Upvote 0

Forum statistics

Threads
1,214,386
Messages
6,119,217
Members
448,876
Latest member
Solitario

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