I'm struggling to understand what you mean, or understand how you've amended my code... The code you amended for me to clear the text in a named range I've set isn't working.
I'm also getting '400' errors on my AddARow and a number of other subs...
I appreciate the support, but feel it is becoming quite fiddly and was wondering if you could provide an answer to my original query in getting the following to work:
Sub ExportSchucoDocument()
Application.ScreenUpdating = False
If MsgBox("An Excel copy will be generated and you'll be notified to save.", vbYesNo) = vbNo Then Exit Sub
Const MODULE_NAME As String = "Schuco"
Const TEMPFILE As String = "C:\Users\" & Environ("username") & "\Documents\Schuco.bas"
ThisWorkbook.VBProject.VBComponents(MODULE_NAME).Export TEMPFILE
Sheets("Schuco Price List").Visible = xlSheetVisible
Sheets("Schuco Rate Sheet").Visible = xlSheetVisible
Sheets("Schuco Schedule").Visible = xlSheetVisible
Sheets(Array("Schuco Front Sheet", "Schuco Schedule", "Schuco Price List", _
"Schuco Rate Sheet")).Select
Sheets("Schuco Rate Sheet").Activate
Sheets(Array("Schuco Front Sheet", "Schuco Schedule", "Schuco Price List", _
"Schuco Rate Sheet")).Copy
ActiveWorkbook.VBProject.VBComponents.Import TEMPFILE
Kill TEMPFILE
MsgBox "Copy saved. The copy will now close." _
& vbCrLf _
& myFile
ActiveWorkbook.Close
Sheets("Schuco Price List").Visible = xlSheetVeryHidden
Sheets("Schuco Rate Sheet").Visible = xlSheetVeryHidden
Sheets("Schuco Schedule").Visible = xlSheetVeryHidden
Application.ScreenUpdating = True
End Sub
As I understand it, I would need to declare it as a variable
Dim strTempFile As String
Then assign it my variable
strTempFile = "C:\Users\" & Environ("username") & "\Documents\Schuco.bas"
I've tried amending my code as follows:
Sub ExportSchucoDocument()
Dim strTempFile As String
Application.ScreenUpdating = False
If MsgBox("An Excel copy will be generated and you'll be notified to save.", vbYesNo) = vbNo Then Exit Sub
Const MODULE_NAME As String = "Schuco"
strTempFile = "C:\Users\" & Environ("username") & "\Documents\Schuco.bas"
ThisWorkbook.VBProject.VBComponents(MODULE_NAME).Export TEMPFILE
Sheets("Schuco Price List").Visible = xlSheetVisible
Sheets("Schuco Rate Sheet").Visible = xlSheetVisible
Sheets("Schuco Schedule").Visible = xlSheetVisible
Sheets(Array("Schuco Front Sheet", "Schuco Schedule", "Schuco Price List", _
"Schuco Rate Sheet")).Select
Sheets("Schuco Rate Sheet").Activate
Sheets(Array("Schuco Front Sheet", "Schuco Schedule", "Schuco Price List", _
"Schuco Rate Sheet")).Copy
ActiveWorkbook.VBProject.VBComponents.Import TEMPFILE
Kill TEMPFILE
Application.Dialogs(xlDialogSaveAs).Show
MsgBox "Copy saved. The copy will now close." _
& vbCrLf _
& myFile
ActiveWorkbook.Close
Sheets("Schuco Price List").Visible = xlSheetVeryHidden
Sheets("Schuco Rate Sheet").Visible = xlSheetVeryHidden
Sheets("Schuco Schedule").Visible = xlSheetVeryHidden
Application.ScreenUpdating = True
End Sub
But when testing, I'm getting the message:
Run-time error '50035'
Method 'Export' of object '_VBComponent' failed
Appreciate all the support you've shown.
Regards
Martin