Naomi,
Sorry but I still did not get my coffee so I can barely understand anything yet.
>Here is the idea of my code:
>
>If I found, that the file I want to create is currently opened by Excel, I want to bring Excel to front, let the users close it, and then proceed with creating Excel and opening it again.
Do you really need user intervention? I do not see the point unless they know they will need to "Save AS", otherwise any changes they will do will be overwrited, wouldn't it?
(And you can ask them from within your application, something like, "This sheet is open and I needit, if you do not want to lose your data, you better give me a alternative name so I can save it for you") and you can automate the saving as
Maybe something like this works for you?
lcFileName = 'SomeDrive:\SomePath\SomeFile.XLS'
loBook = Getobject(lcFileName)
loExcel = loBook.Application
loBook.Close(.f.)
loExcel.Quit()
Now, not sure what will happen if the user has it open the same file multiple times
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?
"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare
"To die for a religion is easier than to live it absolutely"
Jorge L. Borges