Jwalker1973
New Member
- Joined
- Feb 21, 2022
- Messages
- 6
- Office Version
- 365
- Platform
- Windows
- 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
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