Get file details

ChrisUK

Well-known Member
Joined
Sep 3, 2002
Messages
675
Hi,

I wonder if someone can see what I'm doing wrong here

What I thought was a very simple function. In a worksheet cells I have the file name - GetFileDetails("u:\documents\stuff.txt"). I know the file exists but but I always get an error, when I debug it the error is file not found.

Thanks in anticipation

Chris
Code:
Function GetFileDetails(fn As String) As String
'
On Error GoTo ErrHandler

GetFileDetails = FileDateTime("fn")
GoTo EndFunc

ErrHandler:
GetFileDetails = "File Not Found"

EndFunc:

End Function
 
Last edited by a moderator:

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
It should be:
Code:
GetFileDetails = FileDateTime(fn)
without the quotes round "fn".
 
Upvote 0
It should be:
Code:
GetFileDetails = FileDateTime(fn)
without the quotes round "fn".

AHHHHHHHHHHHHHHHHHHH I was looking at that for ages! Funny how the obvious things always evade you.

Thanks

Chris
 
Upvote 0

Forum statistics

Threads
1,214,837
Messages
6,121,883
Members
449,057
Latest member
Moo4247

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top