Compile error :”End with without with” – please help

Status
Not open for further replies.

GizmoL

New Member
Joined
Mar 25, 2019
Messages
4
Hi Guys J,

Could you please look at the below and help me?
When running it I am getting the above error message.
In advance, Thanks a million.
GizmoL.


' email Macro

Set oOutlook = CreateObject("Outlook.Application")Set oNameSpace = oOutlook.GetNameSpace("MAPI")oNameSpace.Logon , , True
ans = MsgBox("Are you sureyou wish to send this email?", vbYesNo)
If (ans = vbYes) Then
Set MItem =oOutlook.CreateItem(0)
With MItem
.To = Range("C4").Value
.Subject =Range("C7").Value
.Body =Range("C6").Value
If (.Range("B8").Value<> "") Then
.Attachments.AddRange("B8").Value
If (.Range("C8").Value<> "") Then
.Attachments.AddRange("C8").Value
If (.Range("D8").Value<> "") Then
.Attachments.AddRange("D8").Value
.Display
End With
End Sub








































 

Some videos you may like

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

Scott T

Well-known Member
Joined
Dec 14, 2016
Messages
2,615
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Your if statements need End IF
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
46,202
Office Version
  1. 365
Platform
  1. Windows
Duplicate https://www.mrexcel.com/forum/excel...rror-end-without-please-help.html#post5248629

Please do not post the same question multiple times. All clarifications, follow-ups, and bumps should be posted back to the original thread.
Per forum rules, posts of a duplicate nature will be locked or deleted (rule 12 here: Forum Rules).

Note that sometimes posts from new users require Moderator approval before you can see them on the public forums. When this happens, you should see a message to that effect when you try to post it.
Please be patient and do not attempt to post the question again.
 
Status
Not open for further replies.

Watch MrExcel Video

Forum statistics

Threads
1,108,806
Messages
5,524,987
Members
409,614
Latest member
wile2u

This Week's Hot Topics

Top