?
Solved

VBA to make a ReadOnly file ReadWrite

Posted on 2010-09-23
1
Medium Priority
?
727 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 29

Accepted Solution

by:
nffvrxqgrcfqvvc earned 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

762 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