Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Disable or remove macros for a workbook to be sent in email...

I am sending an excel workbook by email by a macro in the same excel.
Now obviously, its copy is emailed. But that copy will also contain
macro and all the buttons or controls I have added. Can I remove these
additional things and just send plain text excel containing only data?
Even if I can not remove buttons or any control I have added to current
workbook, it's OK. But I don't want my users to get into my code.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Disable or remove macros for a workbook to be sent in email...

copy the information you want to send to a new workbook and send that. Then
close it without saving changes.

for example, to send the current sheet

Activesheet.copy
Activeworkbook.Send . . .
Activeworkbook.Close SaveChanges:=False

Activesheet.copy makes a copy of the activesheet in a new workbook which is
then the activeworkbook.

buttons would be copied and sheet code as well, but you could remove those
in the copy

http://www.cpearson.com/excel/vbe.htm for sample code on deleting code.

for objects on the sheet

Activesheet.Shapes.SelectAll
Selection.Delete

so
Activesheet.copy
Activesheet.Shapes.Select
Selection.Delete
' code to delete sheet code
Activeworkbook.Send . . .
Activeworkbook.Close SaveChanges:=False



--
Regards,
Tom Ogilvy

wrote in message
oups.com...
I am sending an excel workbook by email by a macro in the same excel.
Now obviously, its copy is emailed. But that copy will also contain
macro and all the buttons or controls I have added. Can I remove these
additional things and just send plain text excel containing only data?
Even if I can not remove buttons or any control I have added to current
workbook, it's OK. But I don't want my users to get into my code.



  #3   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Disable or remove macros for a workbook to be sent in email...

hi,
it is possible with code to make a new file and copy all
the data into it and email the new file which would not
contail macros and buttons.
you did not say how may sheets you have nor how much data
you have.
here is a sniplet of code i use to create a new file in
memory, copy a report to it and mail it to 1 person then
delete the new file after email.

Dim sorce As Range
Dim wb As Workbook
Dim strdate As String
strdate = Format(Now, "mm-dd-yy")
Set sorce = Nothing
On Error Resume Next
Set sorce = Range("BA1:BK30")'this is report i mail
On Error GoTo 0
Application.ScreenUpdating = False
Set wb = Workbooks.Add()
sorce.Copy
With wb.Sheets(1)
.Cells(1).PasteSpecial Paste:=8
' Paste:=8 will copy the column widths in 2k up not 97
.Cells(1).PasteSpecial xlPasteValues, , False, False
.Cells(1).PasteSpecial xlPasteFormats, , False, False
.Cells(1).Select
Application.CutCopyMode = False
End With
With wb
.SaveAs "ThisWorkbook.Name" _
& " " & strdate & ".xls"
.SendMail "lastname, firstname", _
"Name of Report"
.ChangeFileAccess xlReadOnly
Kill .FullName 'deleles new wb after email
.Close False
End With
Application.ScreenUpdating = True
'-----------end sniplet-----------------
if you have more sheets, you may need to declare multiple
sources (source1, source1 ect. )you may need a with clause
for each sheet if more than one.

-----Original Message-----
I am sending an excel workbook by email by a macro in the

same excel.
Now obviously, its copy is emailed. But that copy will

also contain
macro and all the buttons or controls I have added. Can I

remove these
additional things and just send plain text excel

containing only data?
Even if I can not remove buttons or any control I have

added to current
workbook, it's OK. But I don't want my users to get into

my code.

.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Disable or remove macros for a workbook to be sent in email...

create a new file in memory

I guess if that were true, you wouldn't need to use the Kill command with
it. <g

--
Regards,
Tom Ogilvy


wrote in message
...
hi,
it is possible with code to make a new file and copy all
the data into it and email the new file which would not
contail macros and buttons.
you did not say how may sheets you have nor how much data
you have.
here is a sniplet of code i use to create a new file in
memory, copy a report to it and mail it to 1 person then
delete the new file after email.

Dim sorce As Range
Dim wb As Workbook
Dim strdate As String
strdate = Format(Now, "mm-dd-yy")
Set sorce = Nothing
On Error Resume Next
Set sorce = Range("BA1:BK30")'this is report i mail
On Error GoTo 0
Application.ScreenUpdating = False
Set wb = Workbooks.Add()
sorce.Copy
With wb.Sheets(1)
.Cells(1).PasteSpecial Paste:=8
' Paste:=8 will copy the column widths in 2k up not 97
.Cells(1).PasteSpecial xlPasteValues, , False, False
.Cells(1).PasteSpecial xlPasteFormats, , False, False
.Cells(1).Select
Application.CutCopyMode = False
End With
With wb
.SaveAs "ThisWorkbook.Name" _
& " " & strdate & ".xls"
.SendMail "lastname, firstname", _
"Name of Report"
.ChangeFileAccess xlReadOnly
Kill .FullName 'deleles new wb after email
.Close False
End With
Application.ScreenUpdating = True
'-----------end sniplet-----------------
if you have more sheets, you may need to declare multiple
sources (source1, source1 ect. )you may need a with clause
for each sheet if more than one.

-----Original Message-----
I am sending an excel workbook by email by a macro in the

same excel.
Now obviously, its copy is emailed. But that copy will

also contain
macro and all the buttons or controls I have added. Can I

remove these
additional things and just send plain text excel

containing only data?
Even if I can not remove buttons or any control I have

added to current
workbook, it's OK. But I don't want my users to get into

my code.

.



Reply
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
How do I email a workbook without macros getting removed? Jack McNees Excel Discussion (Misc queries) 0 July 31st 09 02:30 PM
How do I send/email macros from my excel workbook to someone else? Drea Excel Worksheet Functions 1 August 10th 05 08:08 PM
Disable Macros when opening workbook Rob[_21_] Excel Programming 7 November 12th 04 09:22 AM
Remove Macros from Workbook ostq Excel Programming 3 September 26th 03 06:21 AM
Suppress the Disable Macros / Enable Macros Dialog Shoji Karai Excel Programming 5 September 24th 03 03:10 AM


All times are GMT +1. The time now is 10:42 AM.

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"