Ron,
I really appreciate the help. I am using Excel 2003.
Thanks, Darrell
Sub E_Desc_file()
'EMAIL "A" SHEET ONLY WITH NO BUTTONS AND FORMULAS
Dim objOL As New Outlook.Application
Dim objMail As MailItem
Set objOL = New Outlook.Application
Set objMail = objOL.CreateItem(olMailItem)
Dim msg As String
i = Range("Discrepancies_Title").Text
j = Range("ShipName").Text
UN = Application.UserName
Sheets("discrepancies").Select
ActiveWindow.DisplayHeadings = False
Sheets(Array("Snapshot", "discrepancies")).Copy
ActiveWorkbook.SaveAs Filename:="M:\Stuff\" & i & ".xls",
FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False,
_
CreateBackup:=False
'DELETE OBJECTS
Application.DisplayAlerts = False
Sheets("discrepancies").Select
ActiveSheet.Shapes("Button 1").Select
Selection.Delete
Application.CommandBars("Control Toolbox").Visible = False
Application.CommandBars("Formatting").Visible = False
Application.CommandBars("Standard").Visible = False
Application.CommandBars("Forms").Visible = False
Application.DisplayStatusBar = False
ActiveWindow.DisplayHeadings = False
'PASTE DATA WITOUT FORMULAS
Application.Goto Reference:="Print_Area"
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
'DELETE REQUIRED COLUMNS & ROWS & FILTER BLANKS
Sheets("discrepancies").Select
Selection.AutoFilter Field:=1, Criteria1:="="
Columns("D
").Select
Selection.Delete Shift:=xlToLeft
Columns("F:G").Select
Selection.Delete Shift:=xlToLeft
Range("B4").Select
Dim sh As Worksheet
Dim rng As Range
Set sh = Sheets("discrepancies")
Set rng = sh.Range("Discrepancies")
'DELETE RANGE NAMES
For Each R In ActiveWorkbook.Names
R.Delete
Next R
Application.DisplayAlerts = False
ActiveWindow.ScrollColumn = 1
ActiveWindow.ScrollRow = 1
ActiveWorkbook.Save
'ActiveWorkbook.Close
msg = "<H3><B>Dear Customer</B></H3>" & _
"Please visit this website to download the new
version.<br>" & _
"Let me know if you have problems.<br>" & _
"<A HREF=""
http://www.rondebruin.nl/"">Ron's Excel
Page</A>" & _
"<br><br><B>Thank you</B>"
'msg = "To whom it may concern:" & Chr(13) & Chr(13)
'msg = msg & "The following discrepancies have been noted in the CSSR
file for " & j & ". Please make any corrections to CostPoint or the
sequence log "
'msg = msg & "as necessary. Please acknowledge corrections or intended
corrections to discrepancies in your cognizance within 24 hours. Your
prompt attention to "
'msg = msg & "these issues is appreciated." & Chr(13)
'msg = msg & "Thanks," & Chr(13) & Chr(13)
Select Case UN
Case "DarrellL"
msg = msg & "Darrell"
Case "WillyM"
msg = msg & "Willy"
Case "AlanM"
msg = msg & "Allan"
Case Default
msg = msg & ""
End Select
addee = "CVN 65"
CC = "(e-mail address removed);
[email protected];
[email protected]"
With objMail
.To = addee
.CC = CC
.Subject = i
.Attachments.Add "M:\Stuff\" & i & ".xls"
'.Body = msg
.HTMLBody = msg & RangetoHTML(sh, rng)
.Display
ActiveWorkbook.Close
End With
Set objMail = Nothing
Set objOL = Nothing
Kill "M:\Stuff\" & i & ".xls"
End Sub
Public Function RangetoHTML(sh As Worksheet, rng As Range)
'Changed by Ron de Bruin 13-Sept-2006
' You can't use this function in Excel 97
Dim TempFile As String
Dim Nwb As Workbook
Dim fso As Object
Dim ts As Object
sh.Copy
Set Nwb = ActiveWorkbook
With Nwb.Sheets(1)
On Error Resume Next
.DrawingObjects.Visible = True
.DrawingObjects.Delete
On Error GoTo 0
End With
TempFile = Environ$("temp") & "/" & _
Format(Now, "dd-mm-yy h-mm-ss") & ".htm"
With Nwb.PublishObjects.Add( _
SourceType:=xlSourceRange, _
Filename:=TempFile, _
Sheet:=sh.Name, _
Source:=rng.Address, _
HtmlType:=xlHtmlStatic)
.Publish (True)
End With
Nwb.Close False
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.GetFile(TempFile).OpenAsTextStream(1, -2)
RangetoHTML = ts.ReadAll
ts.Close
'PublishObjects align center so we change it to left
RangetoHTML = Replace(RangetoHTML, "align=center x
ublishsource=",
"align=left x
ublishsource=")
Set ts = Nothing
Set fso = Nothing
Set Nwb = Nothing
Kill TempFile
End Function