UDF & Add-in Issue

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

All -

I have a UDF that works fine in a regular Excel workbook module. However,
when I convert the excel workbook into an add-in the function no longer
works. I copied it back to a regular Excel module and it works fine. What
am I doing wrong with the conversion of the function to the Add-in?

Here is the function:

Function DoesFileExist (PathFileName as String) as Boolean

On Error GoTo FileDoesNOTExist

If Len(PathFileName) then
If (GetAttr(PathFileName) and vbDirectory) < 1 then
DoesFileExist = True
End if
End if

Exit Function

FileDoesNOTExist:
DoesFileExist = False

End Function

My other UDF work just fine in the Add-in.
Thanks for any help you can give me.

MSweetG222
 
Option Explicit
Sub test()
MsgBox FileExists("C:\Rubbish.xls")
End Sub


Function FileExists(sFileName As String) As Boolean

FileExists = Not ( Dir( sFileName ) = "" )

End Function
 

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

Back
Top