High Plains Grifter
Board Regular
- Joined
- Mar 9, 2010
- Messages
- 129
hello people.
I am confused. I have written a macro which asks various questions of users in message boxes, then copies the results sheet to a new workbook, which is saved with a new name.
So far so good.
However, having saved the results, I wish to close the original questionnaire file without saving changes, so it can be used again by another user. I have used the following code, which appears at the end of the macro, after the quiz has been completed.
(quizname is the codename for this set of answers, and use score, used as the new filename. Quizm is the name of the questionnaire file, which should be closed unaltered, with no notifications to the user).
The Questionnaire file, Quizm is read only with a password, although this may not be relevant. For some reason, when I run the macro I get a window popping up offering to save Quizm as "copy of Quizm". It doesn't even ask me if I want to save it, it just appears with the final save as window. How do I stop this happening?
Any advice most welcome - this is the last thing I need to do to get this working smoothly, and I just can't work it out - the Internet has not been any help so far... :¬(
Thanks for reading!
Mark
I am confused. I have written a macro which asks various questions of users in message boxes, then copies the results sheet to a new workbook, which is saved with a new name.
So far so good.
However, having saved the results, I wish to close the original questionnaire file without saving changes, so it can be used again by another user. I have used the following code, which appears at the end of the macro, after the quiz has been completed.
(quizname is the codename for this set of answers, and use score, used as the new filename. Quizm is the name of the questionnaire file, which should be closed unaltered, with no notifications to the user).
Code:
'...
file = "C:\Documents and Settings\Mark\My Documents\Quiztest\" & quizname & ".xls"
'save the completed quiz
Sheets("Results").Copy
ActiveWorkbook.SaveAs Filename:=file, _
FileFormat:=xlOpenXMLWorkbook, Password:="grifter", WriteResPassword:="grifter", ReadOnlyRecommended:=False, _
CreateBackup:=False
MsgBox "File saved as" & quizname & ".xls", vbInformation, "Quiz Completed - Well Done!"
'Protect the results sheet
Sheets("Results").Protect Password:="grifter"
ScreenUpdating = False
Workbooks("quizm").Close savechanges = False
ScreenUpdating = True
End Sub
The Questionnaire file, Quizm is read only with a password, although this may not be relevant. For some reason, when I run the macro I get a window popping up offering to save Quizm as "copy of Quizm". It doesn't even ask me if I want to save it, it just appears with the final save as window. How do I stop this happening?
Any advice most welcome - this is the last thing I need to do to get this working smoothly, and I just can't work it out - the Internet has not been any help so far... :¬(
Thanks for reading!
Mark