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








































 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

Scott T

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

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
72,989
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.
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,485
Messages
5,831,940
Members
430,096
Latest member
IBRAHEEM NAJJAR

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
Top