Set Read Only

I automatically save a copy of a file to a communal location (Y drive), so 
that other persons may read it, using the following code:

 Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As 
Boolean)
'save copy to Network Storage Folder (Y Drive)
ActiveWorkbook.SaveCopyAs "Y:\" & ActiveWorkbook.Name
End Sub

This works fine but how do I make this copy a read only file?

Peter


0
p.andrews (27)
2/15/2007 7:43:16 PM
excel 39879 articles. 2 followers. Follow

2 Replies
573 Views

Similar Articles

[PageSpeed] 25

You can use SetAttr to change the file to readonly:

    Dim myNewName As String
    
    myNewName = "Y:\" & ActiveWorkbook.Name

    On Error Resume Next 'in case there isn't one there
    SetAttr pathname:=myNewName, attributes:=vbNormal
    On Error GoTo 0
    
    ActiveWorkbook.SaveCopyAs myNewName
    SetAttr pathname:=myNewName, attributes:=vbReadOnly


Peter Andrews wrote:
> 
> I automatically save a copy of a file to a communal location (Y drive), so
> that other persons may read it, using the following code:
> 
>  Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
> Boolean)
> 'save copy to Network Storage Folder (Y Drive)
> ActiveWorkbook.SaveCopyAs "Y:\" & ActiveWorkbook.Name
> End Sub
> 
> This works fine but how do I make this copy a read only file?
> 
> Peter

-- 

Dave Peterson
0
petersod (12005)
2/15/2007 8:19:53 PM
"Dave Peterson" <petersod@verizonXSPAM.net> wrote in message 
news:45D4C069.71909E61@verizonXSPAM.net...
> You can use SetAttr to change the file to readonly:
>
>    Dim myNewName As String
>
>    myNewName = "Y:\" & ActiveWorkbook.Name
>
>    On Error Resume Next 'in case there isn't one there
>    SetAttr pathname:=myNewName, attributes:=vbNormal
>    On Error GoTo 0
>
>    ActiveWorkbook.SaveCopyAs myNewName
>    SetAttr pathname:=myNewName, attributes:=vbReadOnly
>
>
> Peter Andrews wrote:
>>
>> I automatically save a copy of a file to a communal location (Y drive), 
>> so
>> that other persons may read it, using the following code:
>>
>>  Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
>> Boolean)
>> 'save copy to Network Storage Folder (Y Drive)
>> ActiveWorkbook.SaveCopyAs "Y:\" & ActiveWorkbook.Name
>> End Sub
>>
>> This works fine but how do I make this copy a read only file?
>>
>> Peter
>
> -- 
>
> Dave Peterson

Thank you for your solution - however it has highlighted something that has 
nothing to do with Excel.  If I copy a read only file to my (new and first) 
NAS drive the read only attribute is cleared and I cannot set it even by 
using the file properties window - some further investigation is required. 
Thank you for your time.

Peter 


0
p.andrews (27)
2/15/2007 9:15:27 PM
Reply:

Similar Artilces:

How do I set up a Startup Form with Access 2007 ?
Hi When I open a database, I want a certain form to start. This form is going to be used for a menu. Please let me know. Thanks Mark Create a macro named Autoexec. Have action open your form. -- KARL DEWEY Build a little - Test a little "mthornblad@gmail.com" wrote: > Hi > > When I open a database, I want a certain form to start. This form is > going to be used for a menu. > > Please let me know. > > Thanks > Mark > > On Aug 13, 5:24 pm, kasab <ka...@discussions.microsoft.com> wrote: > Alternatively, click the Office button ...

Great Plains should allow setting an inactivity timeout
When anyone logged into Great Plains has been inactive for a prespecified period (e.g. 30 minutes) they should be automatically logged out of the application. ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the button, follow this link to open the suggestion in the Microsoft Web-based Newsreader and then click "I Agree" in the message pane. http://www.microsoft.com/Businesssolutions/Community/NewsGrou...

Change permanantly default chart settings like colour, font..
I use excel to plot graphs for class quite often, and these graphs have to adhere to some criteria like having a white plot area, small crosses for datapoints, etc.. So far, when I plot graphs, Excel will use its default dark grey plot area and big diamond datapoints and Arial bolded font for axis labels, and I will have to change the settings manually.. I was wondering if there is any way of telling Excel to automatically generate a plot with the white background and all that other stuff? changing 30 sets of parameters a week is really getting on my nerves.. :P thanks in advance for...

id() node-set function does not work in .NET 1.1 XML Classes
The id() nodeset XPath function does not appear to work when used with XPathDocument and XslTransformation dot net classes. I am trying to make use of IDREFs in XML that link elements to other elements in the document. The code below demonstrates the problem. I SHOULD be getting a line that says "NODES MATCH". Instead I get a "NO NODES MATCH". All the of the W3C stuff I have found says that this should work. Any ideas? robert sutton ==== HERE IS THE OUTPUT This is element Foo! name is bar ID is idfoo --------------------------- Found reference element, it refers to idfo...

read message
Hi to all How can I disable the option that reply automatic for read message ? thanx Tools->options->email options->tracking options. --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. All unsolicited mail sent to my personal account will be deleted without reading. After furious head scratching, Essam asked: | Hi to all | | How can I disable the option that reply automatic for read message ? | | thanx ...

set a value to another cell
how to set(not get) a cell value to another cell? is it possible? A cell formula can get, but only a macro can set. Some exceptions (manually): Scenarios, Goal Seek, Subtotals, Text to Columns and Advanced Filter, none of which is applicable to your situation. -- Regards from Virginia Beach, Earl Kiosterud www.smokeylake.com ----------------------------------------------------------------------- "news.microsoft.com" <whoknows@microsft.com> wrote in message news:%23kjDDZRoIHA.264@TK2MSFTNGP05.phx.gbl... > how to set(not get) a cell value to another cell? > is it pos...

2 Data Sets on Pie Chart
I would like to show our brand shares AND the share change vs. previous year in a pie chart. I can show the percentage (share), but I haven't been able to add the share pt change to each piece of pie. I tried using secondary axis on the pie chart, but it charted the changes instead of associating it with the share axis. I'm using Excel 2002. Currently, I'm linking text boxes to the share point change for each of the 5-10 brands, but that's getting really messy, and I have to manually move the text boxes every month. Can this be done? Any help is appreciated. Hi Pa...

How do I set the printer margins in Publisher?
I'm trying to print a brochure, but I'm having trouble with the left margin. In the design view I can set the margins and layout the graphics and text exactly as I want. But in the print preview, or actually printing, there is about a 3/4" margin on the left. (No problems with the right, top or bottom margins: they are about 1/4" each.) Please do not tell me this is a printer limitation. This problem does NOT occur in Word, Excel or PowerPoint--only in Publisher! (By the way, why doesn't Publisher have the nice drag-n-drop margins that Word and Excel have?) I am no...

DisplayAlerts and ScreenUpdate will not set to False
In Excel using VBA code Application.DisplayAlerts = False or Application.ScreenUpdating = False. I F8 step thru the code and watch the value of DisplayAlerts. It never reads False. Seems like it worked yesterday? Is there any setting that would stop this from working? Joe More info. I had been looking at DisplayAlerts as I stepped thru the code by placing the mouse curser over the word DisplayAlerts and always said "True". I just used temp = application.DisplayAlerts and debug.print temp and that reads out "False"? So new question. Why? "Joe at Baso&qu...

Cannot read Notes contacts by using Outlook
Hi, all, I have the following installed: MS Outlook 2003 MS Outlook Connector for Domino (Outlook 2003/2002 Add-in: Notes Connector: http://www.microsoft.com/downloads/details.aspx?FamilyID=8ebbba59-5f17-4e52-8980-c4f0dfa92d65&DisplayLang=en) Domino Notes Client 5.0.11 With Outlook Connector, I can smoothly sync between my Outlook and Notes, except that my Outlook cannot sync the Personal Address Book of my Notes. My Outlook can view all the server address book of Notes but cannot view the local Personal Address Book of Notes. What should I do? Many thanks. ...

Set control AfterUpdate event to procedure in another module
Hi, i know i can set a controls AfterUpdate event to a user defined procedure if it is in the same module as the code, however is it possible to set it to a procedure in a different module? i.e. By setting in the OnFormLoad() event: cbo.AfterUpdate = "=Module1.Translate()" I cant get it to work, it just says "the expression you entered has a function name that microsoft office access cannot find". The Translate procedure is public. Any thoughts much appreciated. Thanks in advance, Chris If Module1 is a standard module (not a class module, and not the module of a form...

Setting Up Report
I am having a difficult time figuring this one out! I have a query that is pulling the fields that I need in a report. The fields are: BA Complexity Code NumberOfWorkDaysToCode/Key ES MCK 7 ES LCK 1 ES HCK 7 ES HCK 7 I need my report to look something like this: Number of Days To Code/Key HCK LCK MCK 1 Day 1 2...

How to set up windows email
Please help me set up windows email for me to send and receive email. thank you "hannah" <jjeremiah_2911@yahoo.com> wrote in message news:eaZI3iXKLHA.4120@TK2MSFTNGP02.phx.gbl... > Please help me set up windows email for me to send and receive email. > thank you I see that you posted here with a Yahoo address. Is this a free US based Yahoo address? If so it will not allow POP3 access, so it will not set up in WM. You need to purchase a Yahoo Plus account, see, http://help.yahoo.com/l/us/yahoo/mail/classic/mailplus/overview And use the settings des...

Creation of Sample Data set
Hi all, We are trying to create a Sample Data Set, that can be imported into crm using the Microsoft.Crm.Tools.SampleDataWizard.exe in the same way the Cycleworks data is imported. Is it possible to export an existing CRM deployment data into that format? Does anybody come across any documentation about this subject? Absolutely any clue will be much appreciated, as I didn't find anything on the matter. Thanks Yossi Almog Dynamics Israel There is no option to modify the Microsoft.Crm.Tools.SampleDataWizard.exe Few options: 1. Use Redeployment to bring all the data from "...

Excel not using regional settings
Hi - I have set my regional settings to use brackets (23) for negative numbers. I've set both the number and currency formats to use brackets for negative number. WHen starting Excel, using a new blank workbook, negative numbers entered into a cell do NOT show with brackets? My language is set to English (US) and I've adjusted the formats to use brackets for negative numbers and I've copied to reservered accounts. I also want the date to default to the short date format I've set for the language but it too is not working. Excel will not use the default formats I...

Any way to Export/Import Exchange settings?
Is there a way to Export the settings for the following: Default Policy (E-mail address Policy) Default SMTP Virt Server, Relay Restrictions, Message Delivery Connector Settings. This would be used in a DR situattion. Thank You On Fri, 23 Feb 2007 11:22:00 -0800, TheITDude <TheITDude@discussions.microsoft.com> wrote: >Is there a way to Export the settings for the following: >Default Policy (E-mail address Policy) >Default SMTP Virt Server, Relay Restrictions, Message Delivery >Connector Settings. > >This would be used in a DR situattion. Thank You Sure. Exchange Be...

Excel Personal settings/macros
I am using Excel 2003. I just ordered a new computer and would like to be able to transfer the file/s that contain my personal settings(toolbar set ups for example)/macros/whatever else to the new machine. Is this possible? What files do I need to copy and transfer and where do I find them. Please don't tell me I can't do this. <G> TIA Bill Saved from a previous post: I have a short list of things to copy/update when we change pc's at work. It's not complete, but may help you. Word/Excel files: FileName Use custom.dic personal dictionary *.acl p...

Subform Setting
Hi I would like to know how to cause that the subform can not be on focus? I would like to know how to shrink and grow automatically? Thanks Chipcom, To prevent access to the subform, set the Enabled property of the subform to No. As for shrinking and growing, I assume you mean a continuous view subform whose height is adjusted according to the number of records. Is that right? If so, you would need to write some VBA code to change the height of the subform control, to a value that is calculated by multiplying the number of records by the height of the Detail section of the subfo...

Character set not supported??
Dear all, Our email server is EX5.5. I found that some inbound emails contain the following text and its original email (header + body) is putted into a plain text file "message.txt". Why?? How can I fix it? Thank you very much, Keith <Start Quote> This message uses a character set that is not supported by the Internet Service. To view the original message content, open the attached message. If the text doesn't display correctly, save the attachment to disk, and then open it using a viewer that can display the original character set. <<message.txt>> <...

Retrieving Windows' color settings
How do I retrieve Windows' color settings? For example, the default Windows Text is black and background is white. How do I retrieve the color (RGB values) for the Windows background? Have a look at GetSysColor API Victor "Charles Tam" <CharlesTam@discussions.microsoft.com> wrote in message news:811FC86C-4703-433E-B529-A180F46CED79@microsoft.com... > How do I retrieve Windows' color settings? > For example, the default Windows Text is black and background is white. > > How do I retrieve the color (RGB values) for the Windows background? use SystemPa...

Comparing data sets with +/-1 tolerance using conditional formatin
Please help! This has been puzzling me for hours!! I am using conditional formating to compare one data set with another to see if there are any discrepancies, using green cells for the same and red cells for different data. However, one set of data is rounded to the whole number, but the other set is to 2 decimal places (and has to remain that way). Therefore I need my conditional formating to compare the two data sets, but with a tolerance of plus or minus 1.00. How do I create this formula using conditional formating? CF/ Formula is: =ABS(A1-B1)<=1 -- David Biddulph ...

Messages sent only to me in blue setting not working
For some reason this setting no longer works after we moved to new PCs at our company. Strange because it works for some memebers of our group and not others. Any suggestions would be appreciated. We have absolutely no idea what you are talking about: Please provide: Version of Office/Outlook Where this "mail sent to me" setting? Is this done via a rule? Have you checked your settings against those of people where it does work? --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. Due to the (insert latest virus name here) virus, all...

The Microsoft CRM Outlook add-in failed to initialize the user's language setting
Hello I have CRM 4 + RU7 on server; CRM 4 + RU5 + Office 2007 SP2 + Win 7; I try to upgrade Outlook Client to RU7 but after success install it do not start in Outlook with error : The Microsoft CRM Outlook add-in failed to initialize the user's language setting. Restart Microsoft Outlook and try again. HR=0x80131534. Context=. Function=CAddin::HrActivateAddin. Line=671. How to solve this problem ? B.I. "B.I." wrote: > Hello > > I have CRM 4 + RU7 on server; > CRM 4 + RU5 + Office 2007 SP2 + Win 7; > > I try to upgrade Outlook Client to RU7 but a...

Reading my home email while I'm at work
I have Outlook Express 6 on my computer at home and at work. Is there a way I can check my home email from my office computer? Try posting this in an Outlook Express news group - this is not one of them. Outlook is a part of Microsoft Office and is what this group supports. Outlook Express is a part of Internet Explorer and has its own news groups. You can also find some good Outlook Express information here: http://insideoe.tomsterdam.com --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. Due to the (insert latest virus name here) virus, a...

Won't read or see install disc? #2
Version: 2008 Operating System: Mac OS X 10.5 (Leopard) Processor: Power PC I am trying to install 2008 and the disc will not appear on desktop or in Finder. The disc loads fine on other Macs here at home and this Mac is reading other CDs & DVDs fine. Any ideas why it simply won't see it? On 10/24/09 11:57 PM, in article 59b7f4a1.-1@webcrossing.caR9absDaxw, "Blungld@officeformac.com" <Blungld@officeformac.com> wrote: > I am trying to install 2008 and the disc will not appear on desktop or in > Finder. The disc loads fine on other Macs here at home and this Mac ...