Solved

VBA to make a ReadOnly file ReadWrite

Posted on 2010-09-23
1
712 Views
Last Modified: 2012-05-10
I'm using this code to make copy of a ReadOnly template file.

    fs.Copyfile m_sFolderPathOutputs

When I try to save the file a Save dialog box prompts me to specify the new name and location where I want to save a copy of the file (presumably because the file is ReadOnly).

I'm looking for any way to avoid having this dialog pop up: either a parameter in the Save method that says overwrite the ReadOnly file, or setting DisplayAlerts = False, or VBA to make the file ReadWrite before the save, etc.
0
Comment
Question by:ltdanp22
1 Comment
 
LVL 29

Accepted Solution

by:
nffvrxqgrcfqvvc earned 500 total points
ID: 33744966
You can use SetAttr just before you save and then set it back to readOnly after the save/overwrite.
SetAttr "g:\file.txt", vbNormal

SetAttr "g:\file.txt", vbNormal Or vbReadOnly

Open in new window

0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now