+ Reply to Thread
Results 1 to 3 of 3

UDF & Add-in Issue

  1. #1
    MSweetG222
    Guest

    UDF & Add-in Issue

    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


  2. #2
    Patrick Molloy
    Guest

    RE: UDF & Add-in Issue

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


    Function FileExists(sFileName As String) As Boolean

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

    End Function

    "MSweetG222" wrote:

    > 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
    >


  3. #3
    MSweetG222
    Guest

    RE: UDF & Add-in Issue

    Thank you for your assistance!!

    --
    Thx
    MSweetG222



    "Patrick Molloy" wrote:

    > Option Explicit
    > Sub test()
    > MsgBox FileExists("C:\Rubbish.xls")
    > End Sub
    >
    >
    > Function FileExists(sFileName As String) As Boolean
    >
    > FileExists = Not ( Dir( sFileName ) = "" )
    >
    > End Function
    >
    > "MSweetG222" wrote:
    >
    > > 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
    > >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1