Results 1 to 2 of 2

User Defined Functions as AddIn

Threaded View

DCSwearingen User Defined Functions as... 05-31-2007, 12:40 PM
DCSwearingen Issue Solved! 05-31-2007, 04:03 PM
  1. #1
    Forum Contributor
    Join Date
    03-24-2005
    Location
    Wisconsin
    MS-Off Ver
    2007
    Posts
    378

    User Defined Functions as AddIn - Resolved

    Good morning to everyone.
    I posted a question yesterday at
    http://www.excelforum.com/showthread.php?t=601728
    and the response worked perfectly.

    My problem is that I would like to turn my UDF workbook into an addin.

    I have placed the UDF code into a module, E.g.
    Function Celsius(Deg_F As String)
              ' Convert degrees F to degrees C
    Dim myString
        myString = Deg_F
        If myString = "" Then
            GoTo fn_Exit
        Else
            Celsius = 0.0000000001 + (FormatNumber(Deg_F, 6) - 32) * 5 / 9
        End If
    fn_Exit:
    End Function
    In the regular workbook I can place the code for adding the functions to the Insert Function dialog into the This Workbook Open Event
    Private Sub Workbook_Open()
    On Error GoTo 0
    Application.MacroOptions macro:="Celsius", _
        Description:="Converts Degrees Farenheit to Degrees Celsius", Category:="Conversions"
    End Sub
    Or I can place the code into a module as a subroutine (addFunctions) and call it from the Workbook Open event
    Private Sub Workbook_Open()
    On Error GoTo 0
        addFunctions
    End Sub
    All works as it should.
    When I save as an addin, I can install the addin and all works.

    But as soon as I close out of Excel and open a new Excel window, I get the error message
    Run-time error "1004"
    Cannot edit  a macro on a hidden workbook.  Unhide the workbook using the Unhide command.
    I have deleted the addin, changed the code in the workbook (as above), saved again as an addin, etc.

    Everything still results in the same error when I completely close out of Excel and open a new instance.

    The code that is high lighted when I click to debug is
    Application.MacroOptions macro:="Celsius", _
        Description:="Converts Degrees Farenheit to Degrees Celsius", _
        Category:="Conversions"
    What is the proper way of having these functions installed?
    Last edited by DCSwearingen; 06-19-2007 at 11:34 AM.
    Thanks!
    Dennis

    I am using Windows 7 and Office 2007, all of my posts are based on this.

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