Hi,
I have a form that is used to run a report in excel using a template based on user selections. So there is a VB code and a macro that is used to update the file with query output.
My problem is that when the user makes a selection and runs this report, it runs fine and creates an excel sheet called "customerpricing.xls".
Now if the user tries to run the same report by chosing something else from the form without closing this already created report, then it crashes excel.
So I have to include a code somewhere in the existing code that checks on user machine if "customerpricing.xls" is already open. If its open, then it gives a message to user to close the report. Once user closes the report, he can run the report again.
Or the other option is if the code checks for this file. If its open, then it runs the report but creates file with name "customerpricing_1.xls" and so it just adds _1, _2, _3...and so on to the file name.
Or if there is anyway to stop this from happening by tweaking the code.
I'm attaching the file that contains the code and macro.
Can someone please advise what the best option is and how to make this work?
I have a form that is used to run a report in excel using a template based on user selections. So there is a VB code and a macro that is used to update the file with query output.
My problem is that when the user makes a selection and runs this report, it runs fine and creates an excel sheet called "customerpricing.xls".
Now if the user tries to run the same report by chosing something else from the form without closing this already created report, then it crashes excel.
So I have to include a code somewhere in the existing code that checks on user machine if "customerpricing.xls" is already open. If its open, then it gives a message to user to close the report. Once user closes the report, he can run the report again.
Or the other option is if the code checks for this file. If its open, then it runs the report but creates file with name "customerpricing_1.xls" and so it just adds _1, _2, _3...and so on to the file name.
Or if there is anyway to stop this from happening by tweaking the code.
I'm attaching the file that contains the code and macro.
Can someone please advise what the best option is and how to make this work?