06-06-2017 09:22 AM
@sportsguy99 wrote:
The file name can be changed or could be the same based on the operator's wishes. Thats not important. The GUI can append to a already existing file. But it can only write new data when the CSV file is closed. I only need to make sure the file is closed at the start of the program. Thats the problem, I am having.
Isn't appending writing new data to the end of a file?
06-06-2017 09:30 AM
Yes it is writing to the end of the file. That is fine. I have the program working perfectly but when the file is open, a popup keeps arising saying "file is opened and cannot write new data" or along those lines. I just wish to close the file in the beginning of the program.
06-06-2017 09:39 AM
@sportsguy99 wrote:
Yes it is writing to the end of the file. That is fine. I have the program working perfectly but when the file is open, a popup keeps arising saying "file is opened and cannot write new data" or along those lines. I just wish to close the file in the beginning of the program.
OK, Now things are making sense (maybe- but, I have an exceptionally accurate 8-Ball)
A "The File may be opened in another application! Close the file and try again." error. As Ben mentioned in the first reply, only the owning application can close the file.
06-06-2017 09:43 AM
Yes you are correct. I want to do this for the owning application. I still want to make sure the file is closed.
06-06-2017 09:48 AM
@sportsguy99 wrote:
Yes it is writing to the end of the file. That is fine. I have the program working perfectly but when the file is open, a popup keeps arising saying "file is opened and cannot write new data" or along those lines. I just wish to close the file in the beginning of the program.
This still does not make sense to me...
Program 1 opens a file and when it is done it closes the file, right?
Program 2 opens the file program 1 made, right?
Now you say program 1 tries to open the same file that is already has open or does program 2 still have the file open and program 1 is trying to open the same file again??
06-06-2017 09:51 AM
I am not trying to open any file. I just need to make sure the Excel spreadsheet file is closed in the beginning of the program because the GUI will not append to the excel file without it being closed. I never open any files in this program.
06-06-2017 09:55 AM
You have managed to sump 6 of us (with probably 100 years experience combined) with the question.
I would use my magic-eight ball to answer (but it needs rehydrated).
Are you telling us that Excel has it open?
If that is the case you would have to find the Excel process(s) and close them using OS calls.
If is far easier to pop-up a message saying "File is open please close it and try again".
Ben
06-06-2017 09:58 AM
Yes, that the file is opened in Excel. How would i use OS calls? Is there any other ways? I would rather not make a pop-up message.
06-06-2017 10:02 AM
@sportsguy99 wrote:
I am not trying to open any file. I just need to make sure the Excel spreadsheet file is closed in the beginning of the program because the GUI will not append to the excel file without it being closed. I never open any files in this program.
If you are not opening any files then who is opening the file in Excel?
Sounds like a training issue to me. You have to close the file in Excel before you launch your "GUI" program.
06-06-2017 10:04 AM
Yes, but I want to make my program robust in case of errors if another user uses the program. Just in case they have the file opened when running the GUI, i want my program to close the file.