Afternoon geniuses for VBA,
I have an issue with part of a code written to open an excel workbook, add info in, change the name based on information entered into a VBA userform, and save it into a new directory.
This used to work, but since adding the lines denoted below with a £ at the beginning, whenever run I get 'Do you want to save the changes you made to 'feedback blank 1'?
Clicking yes just pulls up the box again. Clicking No doesn't help. Clicking cancel copies the .Doc file but not the excel one.
I hope I am explaining this well enough, but I cannot see what is causing this. The code can be found below:
Thank you in advance for even reading this, even if you are unable to help.
<code>Dim FName As String
Dim FPath As String
Dim NewBook As Workbook
Dim PPr As String
FPath = sfile
FName = UserForm1.TextBox2 & ", " & UserForm1.TextBox1 & " - Feedbacks" & ".xls"
£ PPr = FPath & "\" & UserForm1.TextBox2 & ", " & UserForm1.TextBox1 & " - Feedbacks" & " PPR" & ".doc"
Set NewBook = Workbooks.Add(ActiveWorkbook.Path & "\feedback blank.xls")
If Dir(FPath & "\" & FName) <> "" Then
MsgBox "This person appears to already exist please double check"
GoTo arrested_development
Else
NewBook.ActiveSheet.Range("B2") = UserForm1.TextBox1.Value & " " & UserForm1.TextBox2.Value
NewBook.ActiveSheet.Range("C2") = UserForm1.TextBox3.Value
NewBook.ActiveSheet.Range("D2") = UserForm1.TextBox4.Value
NewBook.ActiveSheet.Range("E2") = UserForm1.ComboBox1.Value
NewBook.ActiveSheet.Range("F2") = UserForm1.TextBox6.Value
NewBook.ActiveSheet.Range("G2") = UserForm1.TextBox7.Value
NewBook.ActiveSheet.Range("B4") = UserForm1.ComboBox3.Value
NewBook.ActiveSheet.Range("C4") = UserForm1.ComboBox4.Value
NewBook.SaveAs Filename:=FPath & "\" & FName
NewBook.Close
£ FileCopy "S:\Bicester - Talisman House\Programmes\_Offender Info\CDVP\ONE TO ONE PROGRAMME\RESOURCES\HR 1 to 1 SAR - PPR Template.doc", PPr
End If
arrested_development:
</code>
Any help will be gratefully received. If you have any questions. I will try to answer as best i can.
Rhod
I have an issue with part of a code written to open an excel workbook, add info in, change the name based on information entered into a VBA userform, and save it into a new directory.
This used to work, but since adding the lines denoted below with a £ at the beginning, whenever run I get 'Do you want to save the changes you made to 'feedback blank 1'?
Clicking yes just pulls up the box again. Clicking No doesn't help. Clicking cancel copies the .Doc file but not the excel one.
I hope I am explaining this well enough, but I cannot see what is causing this. The code can be found below:
Thank you in advance for even reading this, even if you are unable to help.
<code>Dim FName As String
Dim FPath As String
Dim NewBook As Workbook
Dim PPr As String
FPath = sfile
FName = UserForm1.TextBox2 & ", " & UserForm1.TextBox1 & " - Feedbacks" & ".xls"
£ PPr = FPath & "\" & UserForm1.TextBox2 & ", " & UserForm1.TextBox1 & " - Feedbacks" & " PPR" & ".doc"
Set NewBook = Workbooks.Add(ActiveWorkbook.Path & "\feedback blank.xls")
If Dir(FPath & "\" & FName) <> "" Then
MsgBox "This person appears to already exist please double check"
GoTo arrested_development
Else
NewBook.ActiveSheet.Range("B2") = UserForm1.TextBox1.Value & " " & UserForm1.TextBox2.Value
NewBook.ActiveSheet.Range("C2") = UserForm1.TextBox3.Value
NewBook.ActiveSheet.Range("D2") = UserForm1.TextBox4.Value
NewBook.ActiveSheet.Range("E2") = UserForm1.ComboBox1.Value
NewBook.ActiveSheet.Range("F2") = UserForm1.TextBox6.Value
NewBook.ActiveSheet.Range("G2") = UserForm1.TextBox7.Value
NewBook.ActiveSheet.Range("B4") = UserForm1.ComboBox3.Value
NewBook.ActiveSheet.Range("C4") = UserForm1.ComboBox4.Value
NewBook.SaveAs Filename:=FPath & "\" & FName
NewBook.Close
£ FileCopy "S:\Bicester - Talisman House\Programmes\_Offender Info\CDVP\ONE TO ONE PROGRAMME\RESOURCES\HR 1 to 1 SAR - PPR Template.doc", PPr
End If
arrested_development:
</code>
Any help will be gratefully received. If you have any questions. I will try to answer as best i can.
Rhod