File name from VBA


Posted by Mandy on August 24, 2001 6:47 AM

Can I access file name from within VBA,

i.e. I want to put the file name of any given file into a cell, e.g. "A10"

Any suggestions

Thankyou
Mandy

Posted by Barrie Davidson on August 24, 2001 6:50 AM

Try
Range("A10").Value = ActiveWorkbook.Name

Barrie



Posted by Jerid on August 27, 2001 5:36 AM

Mandy, try this.
Range("A1").Value = Application.GetOpenFilename(, , "Select a File")

You can also use,
Range("A1").Value = Application.GetSaveAsFilename()

They do the same thing, collect the path and file name. The difference is that the GetOpen displays an Open button on the dialog form, and the GetSaveAs displays a Save button and wants the user to enter a file name. (There are a few other differences that you will see also)

Jerid