Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 211
Default add additional code to code

Per
Perfect Thank you!

"Per Jessen" wrote:

Hi

This error indicates that you have an "option explict" statement at the top
of your module, which require that all variables used in this module are
defined.

Add theese lines to the other dim statements.

Dim cell As Range
Dim MsgStr As String
Dim Msg As String
Dim SubjStr As String

Regards,
Per

"Marilyn" skrev i meddelelsen
...
Hello
I made the adjustments as you suggested, but when I run the code I get
compile error variable not defined.
the word "cell" in the line
for each cell in test range
is highlighted. again thanks in advance


"Per Jessen" wrote:

Hi

This should do it:

Sub Mail_Selection_Range_Outlook_Body()
' Don't forget to copy the function RangetoHTML in the module.
' Working in Office 2000-2007
Dim rng As Range
Dim OutApp As Object
Dim OutMail As Object
Dim TestRange As Range

Set TestRange = Range("B16, B19:B20")
For Each Cell In TestRange
If Cell.Value = "" Then
MsgStr = MsgStr & Cell.Address & " "
End If
Next

If MsgStr < "" Then
Msg = MsgBox("You must fill in cell(s) " & MsgStr, vbInformation,
_
"Regards, Per Jessen")
Exit Sub
End If

Set rng = Nothing
On Error Resume Next
'Only the visible cells in the selection
Set rng = Selection.SpecialCells(xlCellTypeVisible)
'You can also use a range if you want
'Set rng =
Sheets("YourSheet").Range("D4:D12").SpecialCells (xlCellTypeVisible)
On Error GoTo 0

If rng 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

With Application
.EnableEvents = False
.ScreenUpdating = False
End With

Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)
SubjStr = "Contract " & Range("B12").Value & Range("A7").Value

On Error Resume Next
With OutMail
.To = "l"
.CC = ""
.BCC = ""
.Subject = SubjStr
.HTMLBody = RangetoHTML(rng)
.Send 'or use .Display
End With
On Error GoTo 0

With Application
.EnableEvents = True
.ScreenUpdating = True
End With

Set OutMail = Nothing
Set OutApp = Nothing
End Sub

Regards,
Per

"Marilyn" skrev i meddelelsen
...
Hello Below is Ron De Bruins send code. How and where do I add
the
following to the code

if range(" B16, B19,B20") if is empty(cell.Value) then
MsbgBox "You must fill in cell" & cell.address

also in the subject line I want
.Subject = " Contract " then the value in cell B12 and A7
thanks in Advance

cc




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Drop Down/List w/Code and Definition, only code entered when selec Spiritdancer Excel Worksheet Functions 2 November 2nd 07 03:57 AM
Convert a Number Code to a Text Code Traye Excel Discussion (Misc queries) 3 April 6th 07 09:54 PM
Unprotect Code Module in Code Damien Excel Discussion (Misc queries) 2 April 18th 06 03:10 PM
copying vba code to a standard code module 1vagrowr Excel Discussion (Misc queries) 2 November 23rd 05 04:00 PM
Write a code by code Excel Discussion (Misc queries) 1 March 23rd 05 02:34 PM


All times are GMT +1. The time now is 01:43 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"