Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 347
Default Save worksheet to seperate file?

I have the following code that saves one sheet to a folder. What I`m after is
to save the sheet so that it can not be altered and rename the tap name to
the contents of cell "E1". Also I would like to keep adding the same sheet to
the same folder but with different Tap name.........ie 2006, 2007, 2008 so on.
Here is the code I have so far:

Private Sub CommandButton1_Click()
Dim myFileName As String
With ActiveWorkbook
Worksheets("Sheet2").Copy 'to new workbook
With ActiveSheet
With .UsedRange
..Copy
..PasteSpecial Paste:=xlPasteValues 'remove formulas???
End With
'pick up the name from some cells???
myFileName = .Range("e1").Value & ".xls"
myFileName = "C:\Documents and Settings\All Users\Desktop\ & myFileName"
..Parent.SaveAs Filename:=myFileName, FileFormat:=xlWorkbookNormal
..Parent.Close savechanges:=False
End With
End With
End Sub



--
George
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 347
Default Save worksheet to seperate file?

Thanks Gary for the reply. That works, but I`m still able to amend the data
on the copied sheet. In other words I want the copy as information only so
that others can not change any of the data on it.
--
George


"Gary Brown" wrote:

Change...

myFileName = "C:\Documents and Settings\All Users\Desktop\ & myFileName"
to
myFileName = "C:\Documents and Settings\All Users\Desktop\" & myFileName

--
HTH,
Gary Brown

If this post was helpful to you, please select ''YES'' at the bottom of the
post.



"George" wrote:

I have the following code that saves one sheet to a folder. What I`m after is
to save the sheet so that it can not be altered and rename the tap name to
the contents of cell "E1". Also I would like to keep adding the same sheet to
the same folder but with different Tap name.........ie 2006, 2007, 2008 so on.
Here is the code I have so far:

Private Sub CommandButton1_Click()
Dim myFileName As String
With ActiveWorkbook
Worksheets("Sheet2").Copy 'to new workbook
With ActiveSheet
With .UsedRange
.Copy
.PasteSpecial Paste:=xlPasteValues 'remove formulas???
End With
'pick up the name from some cells???
myFileName = .Range("e1").Value & ".xls"
myFileName = "C:\Documents and Settings\All Users\Desktop\ & myFileName"
.Parent.SaveAs Filename:=myFileName, FileFormat:=xlWorkbookNormal
.Parent.Close savechanges:=False
End With
End With
End Sub



--
George

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 178
Default Save worksheet to seperate file?

Try this...

'/================================================/
Private Sub CommandButton1_Click()
Dim myFileName As String
With ActiveWorkbook
Worksheets("Sheet2").Copy 'to new workbook
With ActiveSheet
With .UsedRange
.Copy
.PasteSpecial Paste:=xlPasteValues 'remove formulas???
End With
'pick up the name from some cells???
myFileName = .Range("e1").Value & ".xls"
'*** Double protect against changing workbook
'1) Protect the worksheet against inadvertent changes
' EXCEPT for unlocked cells
'2) Password protect the workbook so that it is 'Write'
' protected
'***
'Create password for 'Write' permission for workbook
Dim strPassword As String
strPassword = "George"
'Protect the worksheet so that it can not be changed
' unless individual cells are unlocked
ActiveSheet.Protect DrawingObjects:=True, _
Contents:=True, Scenarios:=True
myFileName = .Range("e1").Value & ".xls"
myFileName = _
"C:\Documents and Settings\All Users\Desktop\" & _
myFileName
Application.DisplayAlerts = False
.Parent.SaveAs Filename:=myFileName, _
FileFormat:=xlNormal, Password:="", _
WriteResPassword:=strPassword, _
ReadOnlyRecommended:=True, _
CreateBackup:=False
.Parent.Close savechanges:=False
Application.DisplayAlerts = True
End With
End With

End Sub
'/================================================/
---
HTH,
Gary Brown

If this post was helpful to you, please select ''YES'' at the bottom of the
post.



"George" wrote:

Thanks Gary for the reply. That works, but I`m still able to amend the data
on the copied sheet. In other words I want the copy as information only so
that others can not change any of the data on it.
--
George


"Gary Brown" wrote:

Change...

myFileName = "C:\Documents and Settings\All Users\Desktop\ & myFileName"
to
myFileName = "C:\Documents and Settings\All Users\Desktop\" & myFileName

--
HTH,
Gary Brown

If this post was helpful to you, please select ''YES'' at the bottom of the
post.



"George" wrote:

I have the following code that saves one sheet to a folder. What I`m after is
to save the sheet so that it can not be altered and rename the tap name to
the contents of cell "E1". Also I would like to keep adding the same sheet to
the same folder but with different Tap name.........ie 2006, 2007, 2008 so on.
Here is the code I have so far:

Private Sub CommandButton1_Click()
Dim myFileName As String
With ActiveWorkbook
Worksheets("Sheet2").Copy 'to new workbook
With ActiveSheet
With .UsedRange
.Copy
.PasteSpecial Paste:=xlPasteValues 'remove formulas???
End With
'pick up the name from some cells???
myFileName = .Range("e1").Value & ".xls"
myFileName = "C:\Documents and Settings\All Users\Desktop\ & myFileName"
.Parent.SaveAs Filename:=myFileName, FileFormat:=xlWorkbookNormal
.Parent.Close savechanges:=False
End With
End With
End Sub



--
George

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 347
Default Save worksheet to seperate file?

Just the job.
Thanks very much.
--
George


"Gary Brown" wrote:

Try this...

'/================================================/
Private Sub CommandButton1_Click()
Dim myFileName As String
With ActiveWorkbook
Worksheets("Sheet2").Copy 'to new workbook
With ActiveSheet
With .UsedRange
.Copy
.PasteSpecial Paste:=xlPasteValues 'remove formulas???
End With
'pick up the name from some cells???
myFileName = .Range("e1").Value & ".xls"
'*** Double protect against changing workbook
'1) Protect the worksheet against inadvertent changes
' EXCEPT for unlocked cells
'2) Password protect the workbook so that it is 'Write'
' protected
'***
'Create password for 'Write' permission for workbook
Dim strPassword As String
strPassword = "George"
'Protect the worksheet so that it can not be changed
' unless individual cells are unlocked
ActiveSheet.Protect DrawingObjects:=True, _
Contents:=True, Scenarios:=True
myFileName = .Range("e1").Value & ".xls"
myFileName = _
"C:\Documents and Settings\All Users\Desktop\" & _
myFileName
Application.DisplayAlerts = False
.Parent.SaveAs Filename:=myFileName, _
FileFormat:=xlNormal, Password:="", _
WriteResPassword:=strPassword, _
ReadOnlyRecommended:=True, _
CreateBackup:=False
.Parent.Close savechanges:=False
Application.DisplayAlerts = True
End With
End With

End Sub
'/================================================/
---
HTH,
Gary Brown

If this post was helpful to you, please select ''YES'' at the bottom of the
post.



"George" wrote:

Thanks Gary for the reply. That works, but I`m still able to amend the data
on the copied sheet. In other words I want the copy as information only so
that others can not change any of the data on it.
--
George


"Gary Brown" wrote:

Change...

myFileName = "C:\Documents and Settings\All Users\Desktop\ & myFileName"
to
myFileName = "C:\Documents and Settings\All Users\Desktop\" & myFileName

--
HTH,
Gary Brown

If this post was helpful to you, please select ''YES'' at the bottom of the
post.



"George" wrote:

I have the following code that saves one sheet to a folder. What I`m after is
to save the sheet so that it can not be altered and rename the tap name to
the contents of cell "E1". Also I would like to keep adding the same sheet to
the same folder but with different Tap name.........ie 2006, 2007, 2008 so on.
Here is the code I have so far:

Private Sub CommandButton1_Click()
Dim myFileName As String
With ActiveWorkbook
Worksheets("Sheet2").Copy 'to new workbook
With ActiveSheet
With .UsedRange
.Copy
.PasteSpecial Paste:=xlPasteValues 'remove formulas???
End With
'pick up the name from some cells???
myFileName = .Range("e1").Value & ".xls"
myFileName = "C:\Documents and Settings\All Users\Desktop\ & myFileName"
.Parent.SaveAs Filename:=myFileName, FileFormat:=xlWorkbookNormal
.Parent.Close savechanges:=False
End With
End With
End Sub



--
George

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
Save a single worksheet in Excel as a single file. Dakota New Users to Excel 4 February 22nd 06 04:46 PM
Additional file with no extension created during File Save As proc Peter Rooney Excel Discussion (Misc queries) 2 August 11th 05 02:48 PM
Excel XP: File name in Title Bar not changed after Save As... Dominic Excel Discussion (Misc queries) 9 August 1st 05 12:58 PM
Macro to save a file as ynissel Excel Discussion (Misc queries) 4 May 26th 05 02:48 PM
Weekly Transaction Processing Ralph Howarth Excel Worksheet Functions 4 January 19th 05 05:37 AM


All times are GMT +1. The time now is 05:38 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"