R
Ronbo
I am trying to e-mail two worksheets from a workbook using the following code
from Ron de Bruin;
Sub MailSheets()
Dim wb As Workbook
Dim strdate As String
strdate = Format(Now, "dd-mm-yy h-mm-ss")
Application.ScreenUpdating = False
Sheets(Array("sheet 1", "sheet 2")).Copy
Set wb = ActiveWorkbook
With wb
.SaveAs "Part of " & ThisWorkbook.Name _
& " " & strdate & ".xls"
.SendMail "xxx.com", _
"This is the Subject line"
.ChangeFileAccess xlReadOnly
Kill .FullName
.Close False
End With
Application.ScreenUpdating = True
End Sub
The problem I have is that the two sheets contain code on activation. So
when the new workbook is created and a sheet activated, it errors from not
having a referenced module "open" used in (application.run "open" ).
Any suggestions as to what I can do to by pass the error, create without the
code or some other way to e-mail two worksheets from a workbook, is as always
greatly appreciated.
from Ron de Bruin;
Sub MailSheets()
Dim wb As Workbook
Dim strdate As String
strdate = Format(Now, "dd-mm-yy h-mm-ss")
Application.ScreenUpdating = False
Sheets(Array("sheet 1", "sheet 2")).Copy
Set wb = ActiveWorkbook
With wb
.SaveAs "Part of " & ThisWorkbook.Name _
& " " & strdate & ".xls"
.SendMail "xxx.com", _
"This is the Subject line"
.ChangeFileAccess xlReadOnly
Kill .FullName
.Close False
End With
Application.ScreenUpdating = True
End Sub
The problem I have is that the two sheets contain code on activation. So
when the new workbook is created and a sheet activated, it errors from not
having a referenced module "open" used in (application.run "open" ).
Any suggestions as to what I can do to by pass the error, create without the
code or some other way to e-mail two worksheets from a workbook, is as always
greatly appreciated.