try ...
....
..HTMLBody = RangeInHtml (Selection)
....
Function RangeInHtml(rng As Range) As String
Dim fso As Object
Dim ts As Object
Dim TempFile As String
Dim TempWB As Workbook
Const ForReading As Long = 1
'Funzione a cui viene passato un range
'restituisce una stringa html che visualizza
'il range
'utilizzabile per creare il testo di messaggi
'di posta elettronica
'Creo un nome di file temporaneo
TempFile = Environ$("temp") & "/" & _
Format(Now, "dd-mm-yy h-mm-ss") & ".htm"
'recupero la cartella del Range passato alla
'funzione
Set TempWB = rng.Parent.Parent
'salvo la cartella come pagina web
With TempWB.PublishObjects.Add( _
SourceType:=xlSourceRange, _
Filename:=TempFile, _
Sheet:=rng.Parent.Name, _
Source:=rng.Address, _
HtmlType:=xlHtmlStatic)
.Publish (True)
End With
'setto FSO
Set fso = CreateObject("Scripting.FileSystemObject")
'recupero il file in lettura
Set ts = fso.GetFile(TempFile). _
OpenAsTextStream(ForReading)
'lo leggo tutto impostando il risultato della funzione
RangeInHtml = ts.ReadAll
'chiudo il file
ts.Close
'di defoult il testo viene disposto al centro
'... meglio a sinistra
RangeInHtml = Replace(RangeInHtml, _
"align=center x

ublishsource=", _
"align=left x

ublishsource=")
'cancello la pagina web creata in precedenza
Kill TempFile
End Function
regards
r
Il mio ultimo lavoro ...
http://excelvba.altervista.org/blog/...ternative.html
"Martin" wrote:
> Hello,
>
> I am trying to send a Mail with a HTML body created from a range. Using the
> following code:
>
> Sub test()
>
> Set OutApp = CreateObject("Outlook.Application")
> OutApp.Session.Logon
> Set OutMail = OutApp.CreateItem(0)
>
> rngesend = Selection
>
> With OutMail
>
> .To = ""
> .CC = ""
> .BCC = ""
> .Subject = "This is the Subject line"
> .HTMLBody =
> ActiveWorkbook.PublishObjects.Add(SourceType:=xlSourceRange,
> Filename:="C:\tempsht.htm", Sheet:=rngesend.Parent.Name,
> Source:=rngesend.Address, HtmlType:=xlHtmlStatic)
> .Display
> End With
>
> End Sub
>
>
> I get an error pop-up at the line where I define the HTML body. Can somebody
> help on this?
>
> Many Thanks
> Martin