copying a workbook into a new file issue

RhodEvans

Board Regular
Joined
Oct 31, 2012
Messages
88
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
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
I have now solved this. It would appear that it was a macro on the target workbook that was causing the issue and by adding

application.enableevents = false

the the beginning and true to the end has fixed it.
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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