Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Protect with "SaveCopyAs"


I am creating a work sheet to be "Saved as" another name, my problem is
I wish to protect it at the time of the "save as".

<snipet
Worksheets("sheet1").Select
Sheets("Sheet1").Copy
ActiveWorkbook.SaveCopyAs vFname 'vFname is new file name as Variant

Any help is appreciated!


--
Rick_Stanich

I am me
------------------------------------------------------------------------
Rick_Stanich's Profile: http://www.excelforum.com/member.php...o&userid=28957
View this thread: http://www.excelforum.com/showthread...hreadid=527358

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Protect with "SaveCopyAs"

It looks like you're copying a single sheet from a workbook and saving that to a
new workbook.

If that's the case, drop the .savecopyas and use .saveas.

Look at VBA's help for its syntax.

Rick_Stanich wrote:

I am creating a work sheet to be "Saved as" another name, my problem is
I wish to protect it at the time of the "save as".

<snipet
Worksheets("sheet1").Select
Sheets("Sheet1").Copy
ActiveWorkbook.SaveCopyAs vFname 'vFname is new file name as Variant

Any help is appreciated!

--
Rick_Stanich

I am me
------------------------------------------------------------------------
Rick_Stanich's Profile: http://www.excelforum.com/member.php...o&userid=28957
View this thread: http://www.excelforum.com/showthread...hreadid=527358


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Protect with "SaveCopyAs"


That was the course of action I originally took, which caused a seperate
problem.
http://www.excelforum.com/showthread.php?t=512358
SaveCopyAs was my work around.


--
Rick_Stanich

I am me
------------------------------------------------------------------------
Rick_Stanich's Profile: http://www.excelforum.com/member.php...o&userid=28957
View this thread: http://www.excelforum.com/showthread...hreadid=527358

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Protect with "SaveCopyAs"

If the code is in the activeworkbook, then one problem is that if you close the
file with the code, then the macro stops at that point.

So this won't get past the .close line:


ActiveWorkbook.Close SaveChanges:=False 'Close new file
'Open original file
Workbooks.Open Filename:=sFname1

You could use:
dim wkbk as workbook
set wkbk = activeworkbook
Workbooks.Open Filename:=sFname1
wkbk.close savechanges:=false


Rick_Stanich wrote:

That was the course of action I originally took, which caused a seperate
problem.
http://www.excelforum.com/showthread.php?t=512358
SaveCopyAs was my work around.

--
Rick_Stanich

I am me
------------------------------------------------------------------------
Rick_Stanich's Profile: http://www.excelforum.com/member.php...o&userid=28957
View this thread: http://www.excelforum.com/showthread...hreadid=527358


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Protect with "SaveCopyAs"

Ps. Instead of using a variable, it looks like you could just use ThisWorkbook.

Workbooks.Open Filename:=sFname1
Thisworkbook.close savechanges:=false

(But the order is still very important.)

Dave Peterson wrote:

If the code is in the activeworkbook, then one problem is that if you close the
file with the code, then the macro stops at that point.

So this won't get past the .close line:

ActiveWorkbook.Close SaveChanges:=False 'Close new file
'Open original file
Workbooks.Open Filename:=sFname1

You could use:
dim wkbk as workbook
set wkbk = activeworkbook
Workbooks.Open Filename:=sFname1
wkbk.close savechanges:=false

Rick_Stanich wrote:

That was the course of action I originally took, which caused a seperate
problem.
http://www.excelforum.com/showthread.php?t=512358
SaveCopyAs was my work around.

--
Rick_Stanich

I am me
------------------------------------------------------------------------
Rick_Stanich's Profile: http://www.excelforum.com/member.php...o&userid=28957
View this thread: http://www.excelforum.com/showthread...hreadid=527358


--

Dave Peterson


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Protect with "SaveCopyAs"


Thank you, I will give it a try!


--
Rick_Stanich

I am me
------------------------------------------------------------------------
Rick_Stanich's Profile: http://www.excelforum.com/member.php...o&userid=28957
View this thread: http://www.excelforum.com/showthread...hreadid=527358

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Protect with "SaveCopyAs"


File name will be changing constantly, hence the variable.

As for protecting the new work sheets, I resorted to protecting the
required sheets prior to "SaveCopyAs" then unprotect the originals
after the operation has completed.

Works ok for me.

'new protect scheme
Sheets("Sheet1").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True
ActiveSheet.EnableSelection = xlNoSelection

'Do some code

ActiveWorkbook.Close SaveChanges:=False 'Close new file
Worksheets("sheet1").Select
ActiveSheet.Unprotect ("****")

'End VBA program

Thanks again for your input!


--
Rick_Stanich

I am me
------------------------------------------------------------------------
Rick_Stanich's Profile: http://www.excelforum.com/member.php...o&userid=28957
View this thread: http://www.excelforum.com/showthread...hreadid=527358

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
Protect "Copy" and "Save As" changes to workbook Jason W Excel Discussion (Misc queries) 3 January 4th 09 01:13 AM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
Add "Protect ALL Sheets" that is the same as "Protect Sheet" KLLuoma Excel Worksheet Functions 0 July 27th 06 07:55 PM
Can I protect columns w/in a "List" using Protect Sheet? Diane Excel Discussion (Misc queries) 0 May 10th 06 03:30 PM
".Protect userinterfaceonly:=True" & ".EnableSelection = xlUnlockedCells" not tabing STEVE BELL Excel Programming 1 February 23rd 06 01:39 AM


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

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"