I posted this somwhere else before but if I here why not repeat.
One day I met a problem, that tou cannot change the name of workbook other than saving it. I programmed same reports in Excel via its OLE and most of them when generated are no use of saving by user, but some are useful. On the other hand, users didn't want to name every file they want to save. When generating, program have information what it generates. For example if user starts menuitem "North region totals of sales" and selects dates Jan 1 to Mar 31 2009, it is natural to name workbook with report like "Sales 2009 Q1". And, again, saving it without of user's desicion may lead to great garbage collection on his HD. So I needed a way to name the neverbeensaved workbook.
The solution was simple and here it is:
1) Create new workbook
2) Save it as template under needed name
3) Close the workbook (which is template now)
4) Create new workbook on the basis of this newly created template
5) delete that newly (in "2") created template
As a result, I have
1) No one extra file on HD (maybe one in Recycled Bin, but I don't mind about it)
2) Workbook, which is new (i.e. never saved) and which have name like <ArbitraryName>1 (maybe <ArbitraryName>2, 3 etc, if it is not first created WB with this instance of Excel)
I posted it becuse I was reading such questions but I never was reading the answer. Sorry if it is because I'm bad reader and this (or other) way is commonplace.
It would be pleasant for me to hear thanks if I helped someone :-)
Bookmarks