Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Protecting New File

I have a simple sub that creates a file, emails the file, then deletes the
file, is it possible to protect the data in the new file in any way. The file
is created from the original file where a range is selected and copied to the
new file.Is it possible to protect the file so that whoever recieves the
email cannot alter the info inside the attachment.
Many Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Protecting New File

Hi MSL

You can protect your worksheet
This example send the selection in a new workbook and protect the sheet (password ron)

Sub Mail_Selection()
Dim source As Range
Dim dest As Workbook
Dim strdate As String

Set source = Nothing
On Error Resume Next
Set source = Selection.SpecialCells(xlCellTypeVisible)
On Error GoTo 0
If source Is Nothing Then
MsgBox "The source is not a range or the sheet is protect, please correct and try again.", vbOKOnly
Exit Sub
End If

If ActiveWindow.SelectedSheets.Count 1 Or _
Selection.Cells.Count = 1 Or _
Selection.Areas.Count 1 Then
MsgBox "An Error occurred :" & vbNewLine & vbNewLine & _
"You have more than one sheet selected." & vbNewLine & _
"You only selected one cell." & vbNewLine & _
"You selected more than one area." & vbNewLine & vbNewLine & _
"Please correct and try again.", vbOKOnly
Exit Sub
End If

Application.ScreenUpdating = False
Set dest = Workbooks.Add(xlWBATWorksheet)
source.Copy
With dest.Sheets(1)
.Cells(1).PasteSpecial Paste:=8
' Paste:=8 will copy the column width in Excel 2000 and higher
' If you use Excel 97 use the other example
.Cells(1).PasteSpecial xlPasteValues, , False, False
.Cells(1).PasteSpecial xlPasteFormats, , False, False
.Cells(1).Select
.Protect "Ron"
Application.CutCopyMode = False
End With

strdate = Format(Now, "dd-mm-yy h-mm-ss")
With dest
.SaveAs "Selection of " & ThisWorkbook.Name _
& " " & strdate & ".xls"
.SendMail ", _
"This is the Subject line"
.ChangeFileAccess xlReadOnly
Kill .FullName
.Close False
End With
Application.ScreenUpdating = True
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"MSL" wrote in message ...
I have a simple sub that creates a file, emails the file, then deletes the
file, is it possible to protect the data in the new file in any way. The file
is created from the original file where a range is selected and copied to the
new file.Is it possible to protect the file so that whoever recieves the
email cannot alter the info inside the attachment.
Many Thanks.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Protecting New File

You can use Tools, Protection to add sheet and workbook protection to make
it more difficult to make changes to an Excel file. This protection is
pretty easy to defeat however.
--
Jim
"MSL" wrote in message
...
|I have a simple sub that creates a file, emails the file, then deletes the
| file, is it possible to protect the data in the new file in any way. The
file
| is created from the original file where a range is selected and copied to
the
| new file.Is it possible to protect the file so that whoever recieves the
| email cannot alter the info inside the attachment.
| Many Thanks.


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
Protecting a file from Copy/Paste ReportSmith Excel Discussion (Misc queries) 2 July 20th 07 06:38 PM
Protecting an Excel file CEP77 Excel Discussion (Misc queries) 3 April 23rd 07 10:21 PM
protecting a file from deletion pmcgr0arty Excel Discussion (Misc queries) 1 March 7th 06 07:39 PM
Password protecting certain worksheets in a file Mike Excel Discussion (Misc queries) 1 March 30th 05 03:53 AM
protecting a csv file lothario[_46_] Excel Programming 1 November 7th 03 12:27 AM


All times are GMT +1. The time now is 08:40 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"