LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Macro help, very slow

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
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
Macro is very slow jlclyde Excel Discussion (Misc queries) 2 September 29th 08 04:43 PM
Slow macro AG Excel Programming 5 August 25th 05 01:25 AM
Slow macro alf bryn Excel Programming 5 August 5th 05 12:27 AM
Macro slow down Jonny Excel Programming 3 February 24th 05 01:29 AM
Macro it's very Slow .... leo_nunez[_2_] Excel Programming 4 August 28th 04 03:45 PM


All times are GMT +1. The time now is 10:55 PM.

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"