Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I had the following macro attached to a button, but I decided to use a double
click instead. I basically just changed the first line. It works, but instead of opening a new outgoing message immediately, it takes about 2 minutes. Can anyone help? Thanks, Scott Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) ' Don't forget to copy the function RangetoHTML in the module. ' Is not working in Office 97 Dim rng As Range Dim OutApp As Object Dim OutMail As Object Dim str As String Set rng = ActiveCell.EntireRow With ActiveSheet If .CheckBox1.Value = True And .CheckBox2.Value = True Then str = .Cells(ActiveCell.Row, "E").Value & ";" & ..Cells(ActiveCell.Row, "I").Value Else If .CheckBox1 = True Then str = .Cells(ActiveCell.Row, "E").Value If .CheckBox2 = True Then str = .Cells(ActiveCell.Row, "I").Value End If End With Application.ScreenUpdating = False Set OutApp = CreateObject("Outlook.Application") Set OutMail = OutApp.CreateItem(0) With OutMail .To = str .CC = "" .BCC = "" .Subject = Cells(ActiveCell.Row, "C").Value .Display 'or use .Send End With Set OutMail = Nothing Set OutApp = Nothing Application.ScreenUpdating = True 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:publishsource=", "align=left x:publishsource=") Set ts = Nothing Set fso = Nothing Set Nwb = Nothing Kill TempFile End Function |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro is very slow | Excel Discussion (Misc queries) | |||
Slow macro | Excel Programming | |||
Slow macro | Excel Programming | |||
Macro slow down | Excel Programming | |||
Macro it's very Slow .... | Excel Programming |