ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Random file name (https://www.excelbanter.com/excel-programming/272206-random-file-name.html)

Robert Melbo

Random file name
 
Is there a way to create a random/unique workbook name in Excel that
can be created by a macro at the beginning, the macro continues on
with its chores, and then, at the end, deletes that workbook? The
workbook is temporary in nature and does not need to exist after the
macro executes.

I am more familiar with writing code in Foxpro than I am with Excel.


Ahí namá,


Robert Melbo

Bob Kilmer

Random file name
 
You could probably get a zillion hits using "unique workbook name" at Google
groups.

http://groups.google.com/grphp?hl=en

Nevertheless, look for the posting from 7/17/2003 whose subject is
"Automatically generate a unique file name via macro"

Bob Kilmer

"Robert Melbo" wrote in message
...
Is there a way to create a random/unique workbook name in Excel that
can be created by a macro at the beginning, the macro continues on
with its chores, and then, at the end, deletes that workbook? The
workbook is temporary in nature and does not need to exist after the
macro executes.

I am more familiar with writing code in Foxpro than I am with Excel.


Ahí namá,


Robert Melbo




Tom Ogilvy

Random file name
 
Just use time as a source for the name - it isn't random, but it shouldn't
be duplicated

sName = Format(now,"yyyymmdd_hhmmss") & ".xls"

to demo from the immediate window:
? Format(now,"yyyymmdd_hhmmss") & ".xls"
20030721_095957.xls


But you can create a new workbook and work with it, then

Activeworkbook.Close SaveChanges:=false

without giving it a name or saving it.

Regards,
Tom Ogilvy

"Robert Melbo" wrote in message
...
Is there a way to create a random/unique workbook name in Excel that
can be created by a macro at the beginning, the macro continues on
with its chores, and then, at the end, deletes that workbook? The
workbook is temporary in nature and does not need to exist after the
macro executes.

I am more familiar with writing code in Foxpro than I am with Excel.


Ahí namá,


Robert Melbo




Keith Willshaw

Random file name
 

"Robert Melbo" wrote in message
...
Is there a way to create a random/unique workbook name in Excel that
can be created by a macro at the beginning, the macro continues on
with its chores, and then, at the end, deletes that workbook? The
workbook is temporary in nature and does not need to exist after the
macro executes.


Why would you want to do this ?

If you open an Excel session you get a workbook who's name
defaults to Book1 but if you dont save it when you close
the session it never gets written to disk anyway.

If you really want a unique name for the workbook generate
a GUID

http://support.microsoft.com:80/supp...NoWebContent=1

Keith



Dana DeLouis[_5_]

Random file name
 
If you really do need to create a temp name, Excel vba has a method that
generates random names. It's advertised for this purpose. You would have
to adjust it to fit your needs. There are many other different options
besides this though.

Sub Demo()
Dim TempFileName
TempFileName = Left$("Excel_" &
CreateObject("Scripting.FileSystemObject").GetTemp Name, 14)
Debug.Print TempFileName
End Sub

returns: Excel_radBD8CE

--
Dana DeLouis
I am using Windows XP & Office XP
= = = = = = = = = = = = = = = = =


"Robert Melbo" wrote in message
...
Is there a way to create a random/unique workbook name in Excel that
can be created by a macro at the beginning, the macro continues on
with its chores, and then, at the end, deletes that workbook? The
workbook is temporary in nature and does not need to exist after the
macro executes.

I am more familiar with writing code in Foxpro than I am with Excel.


Ahí namá,


Robert Melbo





All times are GMT +1. The time now is 11:59 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com