ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

·Q½Ð°Ý¦p¦ó³z¹LVBA±NEXCELªí¤¤ªº¤º®e¡AÂন¹Ï¤ù¨Ã±H¥X

·Q½Ð°Ý¦p¦ó³z¹LVBA±NEXCELªí¤¤ªº¤º®e¡AÂন¹Ï¤ù¨Ã±H¥X

·Q½Ð°Ý¦p¦ó³z¹LVBA±NEXCELªí¤¤ªº¤º®e¡AÂন¹Ï¤ù¡A¨Ã±H¥X¡C
¥Ø«e¦bºô¸ô¤W§ä¨ì¤ñ¸û¥i¦æªº¤èªk¡A¦ü¥G¬O±NbodyÂରhtmlªº¤è¦¡
http://www.rondebruin.nl/mail/folder2/mail4.htm

¦ý¬O¤§«á·Q¨Ì·Ó¤W­±ªº¤è¦¡¡A¥ý§â­ì¥»ªºrange copy¦¨¹Ï¤ù¡A¿é¤J¨ì¼È¦sªºsheet1¤¤¡A
¦ý¬O­n§â³o­Ó¤º®eÂনhtmlªº®É­Ô¦ü¥Gµo¥Í°ÝÃD? ³oÃäµLªkÄ~Äò¹B§@¡C
½Ð¦n¤ß°ª¤â¥i¥HÀ°¦£¡AÁÂÁÂ!!!!


Private Sub CommandButton1_Click()

    Dim rng As Range
    Dim OutApp As Object
    Dim OutMail As Object
    With Application
        .EnableEvents = False
        .ScreenUpdating = False
    End With

    Set rng = Nothing
    Set rng = Sheets("Sent Mail").Range("A1:I240")
    'Set rng = ActiveSheet.UsedRange
    'You can also use a sheet name
    'Set rng = Sheets("YourSheet").UsedRange

    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)

    On Error Resume Next
    With OutMail
        .To = "[email protected]"
        .CC = ""
        .BCC = ""
        .Subject = "This is the Subject line"
        .HTMLBody = RangetoHTML(rng)
        .Display
        '.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

Function RangetoHTML(rng As Range)
' Changed by Ron de Bruin 28-Oct-2006
' Working in Office 2000-2010
    Dim fso As Object
    Dim ts As Object
    Dim TempFile As String
    Dim TempWB As Workbook

    TempFile = Environ$("temp") & "/" & Format(Now, "dd-mm-yy h-mm-ss") & ".htm"

    'Copy the range and create a new workbook to past the data in
    'rng.Copy


    Set TempWB = Workbooks.Add(1)

    rng.CopyPicture Appearance:=xlScreen, Format:=xlPicture
    TempWB.Sheets(1).Paste

    'Publish the sheet to a htm file

    With TempWB.PublishObjects.Add( _

         SourceType:=xlSourcePrintArea, _
         Filename:=TempFile, _
         Sheet:=TempWB.Sheets(1).Name, _
         Source:=TempWB.Sheets(1).Range("A1:I250"), _
         HtmlType:=xlHtmlStatic)
        .Publish (True)
    End With


    'Read all data from the htm file into RangetoHTML
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set ts = fso.GetFile(TempFile).OpenAsTextStream(1, -2)
    RangetoHTML = ts.ReadAll
    ts.Close
    RangetoHTML = Replace(RangetoHTML, "align=center x:publishsource=", _
                          "align=left x:publishsource=")

    'Close TempWB
    TempWB.Close savechanges:=False

    'Delete the htm file we used in this function
    Kill TempFile

    Set ts = Nothing
    Set fso = Nothing
    Set TempWB = Nothing
End Function
50 ¦r¸`¥H¤º
¤£¤ä«ù¦Û©w¸q Discuz! ¥N½X

        ÀR«ä¦Û¦b : ¡i°±º¢¤£«e¡A²×µL©Ò±o¡j¤H³£°g©ó´M§ä©_ÂÝ¡A¦]¦Ó°±º¢¤£«e¡FÁa¨Ï®É¶¡¦A¦h¡B¸ô¦Aªø¡A¤]¤FµL¥Î³B¡A²×µL©Ò±o¡C
ªð¦^¦Cªí ¤W¤@¥DÃD