View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Qaspec Qaspec is offline
external usenet poster
 
Posts: 96
Default Place code from current workbook to new workbook

Is it possible to use the code in my send macro to copy the entire workbook
and then delete the sheets that I don't need before sending via outlook?

"Qaspec" wrote:

I've tried to use the suggestions made in the url. I can't even get to tell
if I can get it to work bacause a) it is specific to modules and b) they set
off the virus scan at my company. They are not going to change the scan so is
there another way to export or copy a sub from the This Workbook section in
one file to the This Workbook section in another file?

"Norman Jones" wrote:

Hi Qaspec,

See Chip Pearson's 'Programming To The Visual Basic Editor' page at:

http://www.cpearson.com/excel/vbe.htm

---
Regards,
Norman



"Qaspec" wrote in message
...
I am using the following code to create a new workbook and send via outlook
to whatever adress the user enters.

Private Sub Send1_Click()
Dim strdate As String
Sheets(Array("Emp24", "Main")).Copy
strdate = Format(Date, "dd-mm-yy") & " " & Format(Time, "h-mm-ss")
Worksheets("Emp24").Name = "NewData"
ActiveWorkbook.SaveAs "NewEmployeeData.xls"
ActiveWorkbook.SendMail "", _
"Employee Attendance Data"
ActiveWorkbook.ChangeFileAccess xlReadOnly
Kill ActiveWorkbook.FullName
ActiveWorkbook.Close False
End Sub

In the original workbook inside the This Workbook section I have the
following:

Private Sub Workbook_Open

Dim lngColor As Long
lngColor = RGB(221, 221, 221)
ActiveWorkbook.Colors(16) = lngColor

End Sub

How can I place this 2nd code into the This Workbook section of the file
being sent i the first sub?

Thank You for any help.