Problem with disabling Read Only attribute

pedro-egoli

Well-known Member
Joined
Apr 25, 2004
Messages
1,217
Office Version
  1. 2016
Platform
  1. Windows
I import an excel file which arrives as (Read only) .
I have gone to files properties and unticked "Read only" and using Office Tab have tried to change the File name from "xyz-11.csv" to "xyz.csv" .
However, after changing name I get a drop down window as below
Excel change name.JPG

Any suggestions on how I can change name without going to Save As procedure
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Have you thought about what the purpose of a file system where you can write a "read only" file and then change it to not being "read only" without actually saving it as something different would be. So if there is a way of doing what you want it rather destroys the purpose of writing a "read only" file. So I am really hoping that you don't find a way round this.
 
Upvote 0
Background is I have a macro which calls the xyz.csv file which replaces an existing saved over existing xyz.csv file.
As i import the file during the day after the first it arrives as xyz-1.csv and then xzyz-2.csv etc.
That is the only reason i want to acheive a workaround
 
Upvote 0
You could get around that by moving the file to another folder once you have processed it, or move it and rename it and include the processed time and date to be really thorough. Then all the files coming in would be without the extra number.
 
Upvote 0
Thanks offthehip, Not quite sure I follow what you are suggesting.
I have no control over the name on file when it arrives and unless I save as .csv it still remains with the -12 or whatever.
Thanks for your suggestion may not have fully understood your suggestion however, i saved it into another file, after it was processed , and when i opened a new edition it still contained the -12 as part of name.
 
Upvote 0
Another alternative would be to change your macro so that it reads the files with names as they arrive. If you always want to process the newest you can read the creation date form the file. Or you could look at the files names an pick the one with the highest number
 
Upvote 0
Thanks again that sounds like a good option
Below is the macro I use
VBA Code:
Sub Sharedata()

'

' Sharedata Macro

'



'

    Windows("AccountBalance.csv").Activate

    Cells.Select

    Selection.Copy

    Windows("Account balances Version-1.xlsm").Activate

    Range("A1").Select

    ActiveSheet.Paste

End Sub
I could easily change "Windows("AccountBalance.csv").Activate" to whatever the address was on imported file.However, is there a way to change code to accomodate changing file titles?
 
Upvote 0
I am not sure what your requirements are but here is some code that copies what is in AccountsBalance.csv and saves it in a new workbook. It determines the new name to call the new files by looking through the folder which it is in toe find the first file number which doesn't exist and then creates a files with this name. Hopefully this will show you what is possible
VBA Code:
Sub findfiles1()
    Set FSO = CreateObject("Scripting.FileSystemObject")


pathn = ActiveWorkbook.Path
 ' limit loop to 100 just in case
  For i = 1 To 100
    filenm = "Account balances Version-" & i & ".xlsm"
    sfile = pathn & "\" & filenm
    'Check File Exists or Not
    If Not (FSO.FileExists(sfile)) Then
      ' first name that doesn't exist
     Exit For
    End If
  Next i
 
    MsgBox sfile
    MsgBox filenm
    Windows("AccountBalance.csv").Activate
    Cells.Select
    Selection.Copy
    Workbooks.Add
    Range("A1").Select
    ActiveSheet.Paste
    ActiveWorkbook.SaveAs Filename:=filenm, FileFormat:=xlWorkbookNormal
    

End Sub
the msgbox are just there to show you what is happening, delete them when you need to
 
Upvote 0
I am pleased to help, and the read only files stay read only!!
 
Upvote 0

Forum statistics

Threads
1,214,585
Messages
6,120,397
Members
448,957
Latest member
Hat4Life

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top