Save copy as read only issues

Jwalker1973

New Member
Joined
Feb 21, 2022
Messages
6
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
Good morning folks,
I am having an issue saving my copy as read only. I have a master excel workbook that I use to save a copy to a specific folder on set up and production issues that I encounter on my machines. When I try to make the copy read only I am getting a run time error 76 Path not found. I am sure it is probably a syntax error of some type I am over looking. I thought I would appeal to the community to see if anyone notices what I am missing

Private Sub CommandButton1_Click()

If Len(Dir("C:\Users\hub204\Documents\Set Up Trend Data\ " & Sheet1.TextBox1.Value, vbDirectory)) = 0 Then
MkDir "C:\Users\hub204\Documents\Set Up Trend Data\ " & Sheet1.TextBox1.Value
End If
Dim Filepath As String
Dim Filename1 As String
Dim Filename2 As String
Dim Filename3 As String

Application.EnableEvents = False



Filepath = "C:\Users\hub204\Documents\Set Up Trend Data\ " & Sheet1.TextBox1.Value & "\"
Filename1 = Sheet1.TextBox2.Value
Filename2 = Sheet1.TextBox5.Value
Filename3 = Sheet1.TextBox6.Value

ActiveWorkbook.SaveCopyAs Filepath & Filename1 & "-" & Filename2 & "-" & Filename3 & ".xls"
SetAttr Filepath & Filename1 & "-" & Filename2 & "-" & Filename3, vbReadOnly

Sheet1.TextBox1.Value = ""
Sheet1.TextBox2.Value = ""
Sheet1.TextBox3.Value = ""
Sheet1.TextBox4.Value = ""
Sheet1.TextBox5.Value = ""
Sheet1.TextBox6.Value = ""
Application.EnableEvents = True


End Sub
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
When I try to make the copy read only I am getting a run time error 76 Path not found. I am sure it is probably a syntax error of some type I am over looking. I thought I would appeal to the community to see if anyone notices what I am missing


Try adding the file extension:

VBA Code:
    SetAttr FilePath & Filename1 & "-" & Filename2 & "-" & Filename3 & ".xls", vbReadOnly
 
Upvote 0
Solution
Thanks that fixed the error. Unfortunately it is not stopping people from editing textboxes. I'll have to find another way.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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