Saving A Back-up File As "Read Only"

Mar 18, 2008

I am using XP and Excel 2003 and I have a workbook that I currently back up to a remote server whenever closing out the book. This back-up copy becomes a "controlled document" that should not be used or changed once it is created. Is there anyway to make it save as a "Read Only" file, so that no one can modify the back-up copy.

Currently I do it manually, but that is becoming tiresome as well as when I forget that nice little error message pops up and....

This is my code so far:


Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim Msg As String
Dim Ans As Integer
Dim FName As String
Msg = "Would you like to make a back-up of this file?"
Ans = MsgBox(Msg, vbYesNo, Title)
Title = "Team Facilities"
If Ans = vbYes Then
FName = "P:Facilities Departmentackups2007" & ThisWorkbook.Name
ThisWorkbook.SaveCopyAs FName
End If
End Sub

View 9 Replies


ADVERTISEMENT

How To Read And Set Cell Back Color In VBA

May 24, 2013

How to read and set a cell backcolor in VBA ?

I've tried all sorts of things ( interior. colour, interior.colorIndex) but nothing gets the correct color.

View 5 Replies View Related

Keep/Retain Values Of Dtpicker Controls & Read Back

Sep 9, 2006

In a userform I have 6 DTPlcker controls for 3 periods (from...to... X3). The dates chosen are not saved unfortunately and once I exit and retrieve the file again all the dates in the 6 DTpickers get the date of today.

View 7 Replies View Related

File May Be Read-Only, Or You May Be Trying To Access A Read-Only Location

Jan 4, 2007

I'm trying to open a file on a network drive...but I'm getting the following error message when it opens: "This file may be read-only, or you may be trying to access a read-only location. Or the server the document is stored on may not be responding." Now, the file itself has no rights restrictions and is not read only. It doesn't appear to be locked.

Now, there are other Excel files in the same directory which I could open fine; however, the Excel documents having the above problem all have a little black icon "appears to be a padlock" (image attached) at the bottom left hand side of the Excel file icon. I tried the following:

- Renaming
- Converting to a different file format (didn't work, it won't let me)
- Opening in notepad...etc doesn't work.

This file is dated back in 2004...do you think it's corrupt? Is there anything i can do to open or recover this?

View 2 Replies View Related

Saving A File Without Saving Macro

Jan 30, 2003

I have a spreadsheet that imports data, manipulates it then deletes 2 of the sheets then saves the file under a different name to the network. Is there any way to save this new worksheet without it storing the macros - so when the user open it, only the data is there and they get no prompt to enable macros?

View 6 Replies View Related

Saving Cell Contents To XML File Saved As Current Workbook File Name

Dec 12, 2012

I have numerous spreadsheets that I need to open and unhide a sheet, that has XML data stored in cell A1. What I need to do is copy that data in cell A1 and paste it into a text document and save that as an XML file saved as the XLS workbook name with a date stamp.

I'm running into many issues, the main issue is the saving as current file name, and the formatting of the text/XML file.

Here is my current code, which doesn't reference the current file name and is just very generic. Once I get the saving as file-name correct and the formatting of the xml file correct, I will work on it a bit more.

Code:
Sub Test()
Dim Rng As Range
Dim wb As Workbook
Set Rng = Range("A1:A2")
Set wb = Workbooks.Add
With wb
Rng.Copy

[code]....

View 4 Replies View Related

VBA For Bypassing Replace File Prompt When Saving As A File In Macro

Jul 7, 2008

I am setting up a "save as" macro that saves a file by replacing another file in a folder. Even though the macro has been recorded by approving the replacement (the prompt appears "the file --- already exists. Do you want to replace the existing file?"), when I run the macro, I am again prompted about replacing the file. Is it possible to avoid the prompt so the file is automatically saved by replacing the named file?

View 9 Replies View Related

Moving Columns Of Data Into Another File And Saving File With New Filename?

Aug 30, 2013

I was wondering if there is a way to write a macro that will take an excel file that I have called Alldata and then have it copy the first two sheets to a new workbook named something else( FullSparameter_0) and then copy the name of the third and fourth sheet into the new FullSparameter_0 workbook and then copy column A-E from sheet dB Alldata.xls and paste it into the FullSparameter_0.xls workbook in the same dB sheet in the same spot. And do the same thing with the Phase Sheet. i know this sounds confusing, but im really new to the VBA stuff.

I just need 15 different files from the original Alldata.xls that will be named FullSparameter_0, FullSparameter_1, .., FullSparameter_14. but each file will have the same two first sheets, Setup Information and Cal Verification, and the same last two sheet names, dB and Phase, but then in the dB and phase sheets, it will copy over the next four columns of data. so in FullSparameter_0 it will have column A-E from sheet dB in Alldata.xls in the dB sheet in FullSparameter_0 (Same with the Phase Sheets). Then in FullSparameter_1 it will have column A and Columns F,G,H and I (for dB and Phase). In fullSparameter_2 it will have column A and then J,K,L and M. Each FullSparameter_X will have the exact same first two sheets and then the other columns for the last two sheets will be pasted into columns A-E in dB and Phase.

View 1 Replies View Related

Saving Multiple Workbooks At One Time/file As A Text File

Mar 16, 2007

found the following code which works for 1 workbook at a time. I am trying to save 7 workbooks at 1 time. Is it possible?

Sub SaveAsCell()
Dim strName As String

On Error Goto InvalidName
strName = Sheet1. Range("V77")
ActiveWorkbook.SaveAs strName

It will work on the first sheet but none after that. I need to have each workbook saved with the value in cell V77. Also if that is possible, is it possible to change where the file is saved as well?

Right now I have a master workbook that will open the 7 other workbooks, paste data onto several pages in each workbook. I would like the macro to save the workbooks. The workbooks are named: 02 Tuesday, 03 Wednesday, 04 Thursday, 05 Friday, 06 Saturday, 07 Sunday, 08 Monday.

View 9 Replies View Related

Saving A File With Specific File Name Using Macro

Feb 18, 2009

I am trying to save my workbook in a specific directory with a specific filename and to incorporate a date field from within the spreadsheet. I have changed the format of the cell so it does not include / as i know this would not work. Saving it is the easy part but adding in the field from the spreadsheet is where im falling over.

View 2 Replies View Related

Back Up File On Save

Jul 2, 2009

I am currently using this code which automatically saves a back up copy to another location on my system.

However, the only way i can get it to work is to assign it to a command button. Is there any way in which this will work once i just click the save button.

View 4 Replies View Related

Workbook_close To Back-up File

Dec 7, 2009

I am currently using this method to create a back-up of the current workbook to another location using a yes/no message box.

If the user clicks no, the workbook will be closed...also if they have not saved any changed data excel also gives them this option in case they close by mistake.

Its the yes option i am having issues with.

If they click yes...the back-up code runs fine and saves the file elsewhere...but for some reason the code loops and runs again. Not sure why this is happening but i do not want it to. Also again if there is any unsaved changes...excel does not give them the option to save this first...i would like this happen.

View 3 Replies View Related

How To Read CSV File

Sep 14, 2012

I used to read *.txt file into C/C++ program?

Now from Yahoo downloading stock prices, they are in EXCEL *.csv format. How can read them into C/C++ program?

View 5 Replies View Related

Read Only File

Apr 10, 2007

Is that possible that I can make an excel file as a read only through code... and if needed should be opened by giving password ?

View 6 Replies View Related

Read Text File Using VBA

Jan 5, 2005

I know how to pull an entire text file
into an Excel Spreadsheet, but I only want specific information from
the text file not the entire text file.

What I have is about 25 text files stored in a folder, let's say
C: est.

Each file is named by a property address as follows:
209 MAIN ST.txt
213 MAIN ST.txt
111 ELM ST.txt
2356 WOOD AVE.txt

On the 11th row of each file is as follows:
Property Address:209 MAIN ST
On the 31st row of each file is as follows:
Total Value:30500

What I would like to do is read each file located in the "C: est
folder and write a record (row) into a single Excel Spreadsheet for
each property. I would like the Excel Spreadsheet to look as follows
once completed. Note the 1st row below is a header row that needs to
be generated by the code.

Property AddressTotal Value
209 MAIN ST 30500
213 MAIN ST 60700
111 ELM ST 20400
2356 WOOD AVE 20900

Can I read a header list (in a spreadsheet, text file, or hard coded in
the code) which I would prefer the spreadsheet or text file method,
write the header row in A1 then B1. Next read the 25 text files and
search based on the header info written above (Property Address & Total
Value) and write the appropriate to the single spreadsheet. The 11th
row of the First text file value written in cell A2, then read the 31st
row of the First text file write the value in cell B2, then loop to the
Second text file and values from The 11th row of the Second text file
value written in cell A3, then read the 31st row of the Second text
file write the value in cell B3, so on and so forth until the last text
file is read and the last record is written.

View 14 Replies View Related

To Read A File And To Make Changes Using VBA

Aug 21, 2009

I have attached three excel files .....In the file called 'sampleBook1latest' I have a button called 'click here to clear a schedule' If I click that button and choose OR,start time and duration of a surgery then a schedule that is already created wil get cleared.....I have the total number of nurses and number of nurses used saved to the side of the sheet..... The total number of nurses at the side is read from another excel file called 'Input file for # of nurses'

Now the problem is that if clear a schedule then the number of nurses used is not getting updated at the side.....if I clear a schedule then the number of nurses at the side should also get updated....for example(If I create a schedule with 3 nurses and if only a total of 3 nurses are available then..... the used number of nurses for that specific time at the side will get updated to 3 from 0 and if I clear that schedule then the used nurses for that time should again become 0)....

The other problem is that if I schedule a surgery then all details of the surgery will be saved in another excel sheet called 'input file for patient details' so if I clear a schedule then all the details of that surgery saved in that excel sheet should also be cleared......

View 11 Replies View Related

Open File Only If Not Read-Only

Jan 16, 2010

1. Check if file is already open
a) If Not then Open the File
b) If It is Open then Show Message That File is Open And Will Load Once the user close it.

2. Check When the file is Closed And Open it

View 3 Replies View Related

VBA Changing File To Read Only?

Oct 30, 2012

I am trying to use code in a VBA macro to change my file to a read-only file at the end of the macro after I've done a few other things to the file. I'm using this line of code:

ActiveWorkbook.ChangeFileAccess xlReadOnly

This code does in fact change the file to read-only. After the macro finishes I see "Read-Only" in the title of the file. However, when I close the file and re-open it the file is no longer read only.

I've tried changing the code to this:

ActiveWorkbook.ChangeFileAccess xlReadOnly
ActiveWorkbook.Save

But that doesn't work because it tells me I can't save the file after it's been converted to read-only.

View 1 Replies View Related

Make A File Read Only

Aug 30, 2007

I need to make a workbook read only depending upon certain conditions that are apparent only on start up. As I cannot assign the ReadOnly property, is my only solution to trap the Save command and dissallow "save changes".

View 9 Replies View Related

Open Read Only File

Oct 7, 2008

I have a workbook set up with hidden worksheets available only with a password. What I would like to do is set this up so that those employees who have the password will have full rights to make changes, while those who don't have the password will have "read only" rights. It should always open as a "read only" file, and then change to full rights when you enter the correct password.

I've also set this up so that it cannot be printed; can I also set it up so that it cannot be saved anywhere on our local drive?

I have the macro set up to limit the access via a password, but don't know where or how to set up these other changes.

View 9 Replies View Related

VBS To Open Excel File As Read Only?

Jan 31, 2014

I have a excel file that opens and will automatically run a bunch of tasks if a certain user opens it. This user is only used to automatically run this excel file, other users need to open the file occasionally to edit emails address, add clients etc stuff like that, that the automation part of it works off.

Currently I have this user running the file every hour using Win7 Task Scheduler. This is working well, except for the time when another user is editing the file on the hour and of course the Automated user gets the "this file is open blah blah blah, open as read only, cancel etc" popup, this stalls everything, and if I dont notice it, it could sit like this for days.

The file runs in Read Only fine, so... Basically my question is, how to open this file as "Read Only" using Task Scheduler? As if it just ran as Read Only all the time then it wouldnt matter what other users were editing at any given time.

One of my ideas was to have Task Scheduler run a VBS script instead of running the Excel file directly, and having the VBS script simply load the Excel as Read Only.

View 5 Replies View Related

How To Speed Up Binary File Read

Apr 9, 2014

I have written a little test sub which reads the contents of a binary file, which is approximately 0.2 Mb in size, into a byte array.

My sub is as follows:

[Code]...

It works just fine, BUT, it is incredibly slow (it spends 80 seconds in the For loop!!!!!)

How can I speed this up?

Note that the binary file can be of arbitrary size.

I tried using a string buffer filled with zeros, and it works!

View 1 Replies View Related

VBA To Read Data From A Text File

Feb 25, 2009

I have written a VBA to read data from a text file (almost 5 MB = 2 lakh rows) and write into excel file. The script runs fine and transfers all data to the excel.But when i open the resulting excel file, only the first 2 and the last worksheets are visible. The worksheets in between and the data in it are missing. Second issue is tht, although i have written code to create a new worksheet when row number reaches 65535, the script writes only till row no. 32768.

View 2 Replies View Related

VBA - Open File NOT In Read Only Mode

Nov 27, 2011

I have a VBA script that has been running fine for months on one computer. Today, I ran it on another computer and it opened files in read only mode which disrupted everything.

The file open command is the following:

Workbooks.Open Filename:=sourcePath & sourceFileName

I searched the entire project and appended ", readonly:=false" to every open command. So, the command became

Workbooks.Open Filename:=sourcePath & sourceFileName, readonly:=false

Still, Excel opened the file in read only mode as seen in the title bar (filename [read-only]).

If I double-clicked on the file and opened it, it's NOT in read only mode. I checked the property of the file. It is NOT read only.

View 2 Replies View Related

VBA To Read In Delimited Text File

May 21, 2014

I've a word form that collects free text and tick boxes. I'm reading these into separate rows on an excel sheets. So far what works...

I've got excel vba converting the word to a delimited text file
I've got excel vba to remove the erroneous rtns that people have entered into the free text that was things up.

In the free text there are commas entered as well as the tick boxes and this is a csv. Example
"how do I do this, I don't know",1,1,0,1,"really seems to be a challenge!"

If I just use excel to open the text file then the columns work out ok and on a single row - I think the 'text qualifier' is playing a role here.

But I can't replicate this in VBA. If I record a macro it's a query table and I don't know how to amend the code to read into rows.

View 2 Replies View Related

Read & Write Mp3 File Tag Properties

May 31, 2008

The problem with the Write macro was that, although it did work, it used SendKeys which has to be slowed down considerably.

Here is a new version of the Write macro that works as normal. I originally tried to use CDDBControl.dll version 1.2.0.51 which is widely available on the internet but found that I could only get it to change 1 file before crashing Excel.

I have put the READ macro in the next message.

Dim ws As Worksheet
Dim FromRow As Long
Dim LastRow As Long
Dim FilesToChange As Integer ' number of files to change
Dim FilesChanged As Integer ' number of files changed
Dim MyFilePathName As String ' full path & file name
Dim MyFileType As String ' mp3 wma etc.
'-
Dim id3 As Object
Dim MyArtist As String
Dim MyAlbum As String
Dim MyGenre As String
Dim MyTrack As String
Dim MyTitle As String

Sub WRITE_TO_EXPLORER()
Application.Calculation = xlCalculationManual
Set ws = ActiveSheet
Set id3 = CreateObject("CDDBControlRoxio.CddbID3Tag")
LastRow = ws.Range("A65536").End(xlUp).Row ' count worksheet rows
FilesToChange = ws.Range("A2:A" & LastRow).SpecialCells(xlCellTypeVisible).Count
If FilesToChange = 0 Then MsgBox ("No files to change."): Exit Sub
FilesChanged = 0........................

View 3 Replies View Related

Read-Write Popup - File Now Available

Apr 29, 2009

I have a tool that accesses a master sheet. Multiple people use the tool (sort of a user interface).

In some cases I need to write to the Master in which I check to make sure its not read only when the macro opens it (that works fine).

In other cases, like when just pulling information, read only is fine. But, I have not specified read only when I open the master.
Sometimes the users are getting a "File Now Available" with a read-write and cancel option. I do not want them to get this message.

My current universal call to master looks like this: ...

View 9 Replies View Related

Read Each Line Of Text File

Oct 26, 2006

I'm using the following code to read a text file that I downloaded from a mainframe file.

Do While Not EOF(FileNum)
Line Input #FileNum, myLine
Debug.Print myLine
Loop

It reads and prints the first line, but then drops out of the loop. According to the help file, "Line Input" is looking for a carriage return (Chr(13)) or carriage return–linefeed (Chr(13) + Chr(10)) sequence. I have pasted a sample of the text file below. I'm not sure what the characters are at the beginning of each line, but perhaps I could find a way to replace each of them with a carriage return.

SAMPLE:............................

View 4 Replies View Related

Code To Open A Read Only .xl File

Jan 11, 2007

I have a read only excel file which I want to interrogate in another report.

I'm writing some code to open the file but I'm not sure how to get past the password/read-only prompt when opening the file.

My code is:

Workbooks.Open Filename:= "C:Sales2006.xls"

I assume it's possible to write some code to get past the prompt. I have checked the help files which do seem to indicate it's possible to specify a read only property but it doesn't say how.

View 5 Replies View Related

Export Ranges To Text File & Import Back

May 14, 2007

I have been copying the work sheet ranges
"Consolidated Data" D4:K17
"Support Schedule" D5:W504
"Tangent Calx1" D4:F34 , J4:J34 and M4:M34
"Tangent Calx2" D4:F34 , J4:J34 and M4:M34
To a seperate worksheet for export to a txt file {for saving}
Then {when required} importing the txt file data into the worksheet ,copy the data back to the worksheet ranges and re-calculating the data. I have struggled to trying and butcher the code and delete the copy stage and write just the required ranges to the txtfile.(And reverse)

View 8 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved