File Name and Full Path Name

J

Jess

How can I get in excel the file name and the full path to the file? Is there
a VBA command that retrieves this info?

Thanks
 
M

Mike H

Hi

mypath = ThisWorkbook.FullName
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.
 
J

Jess

How can I also create a footer whose content is the full path followed by the
file name?

Thanks
 
D

Dave Peterson

Dim wkbk as workbook
set wkbk = activeworkbook 'thisworkbook or workbooks("book1.xls")

msgbox wkbk.name
msgbox wkbk.Fullname
msgbox wkbk.Path

If you're creating a new workbook in your code and you want to test to see if
it's been saved:

if wkbk.path = "" then
'not saved
else
'saved
end if
 
G

Gord Dibben

Delete what you don't want.

Sub PathInFooter()
ActiveSheet.PageSetup.RightFooter = ActiveWorkbook.FullName & " " & _
ActiveSheet.Name & " " & Application.UserName & " " & Date
End Sub


Gord Dibben MS Excel MVP
 
R

Ryan H

Choose Insert Footer and put this in the Left, Center, or Right Footer

&[Path]&[File]&[File]

Hope this helps! If so, let me know, click "YES" below.
 

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