Error every other run
Hello,
I seem to have a strange problem. Every 2nd time I run my Macro, my range
is nothing (thereby causing an error). If I just re-run it, it works fine.
Any suggestions would be great. Below is part of my code. The macro turns a
range into an htm file and inserts it into an email.
Thanks,
WB1.Sheets("Template").Activate
Dim rngh As Range
Dim OutApp As Object
Dim OutMail As Object
With Application
.EnableEvents = False
.ScreenUpdating = False
End With
On Error Resume Next
'Only the visible cells in the selection
Set rngh =
Sheets("Template").Range("A5:f26").SpecialCells(xl CellTypeVisible)
On Error GoTo 0
If rngh Is Nothing Then
MsgBox "The selection is not a range or the sheet is protected" & _
vbNewLine & "please correct and try again.", vbOKOnly
Exit Sub
End If
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)
|