returning filename in excel

C

Claud Balls

In MS Word I used:
With Dialogs(wdDialogFileOpen)
If .Display Then
strSourceFile = WordBasic.FilenameInfo$(.Name, 1)
End If
End With

to obtain the filename of the active document. How can I do this in
Excel?


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
N

Nick Hodge

Claud

To get the filename of the activeworkbook, use

sFileName=ActiveWorkbook.FullName

If you want to display the open dialog and then open a workbook

sFilename=Application.GetOpenFileName()
Workbooks.Open FileName:=sFileName

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
(e-mail address removed)
 
B

Bob Phillips

Claud,

Check out the GetOpenFilename method in VBA help.

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
J

JE McGimpsey

One way:

strSourceFile = ActiveWorkbook.Name

or, if you want the path, too

strSourceFile = ActiveWorkbook.FullName
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top