Calling an Excel Customed Function Within MS Access

keirnus

Registered User.
Local time
Today, 21:09
Joined
Aug 12, 2008
Messages
99
Hello once again...

I made a function in Excel. The function does some error checking within the Excel file.

To be easy for me, I want my code in MS Access to simply call the function in Excel.

I check this MS Support site: http://support.microsoft.com/kb/198571
I tried calling my function and it didn't work.

Here's my MS Access code:
Code:
    Dim oXL As Excel.Application    ' Excel Application
 
    Set oXL = CreateObject("Excel.application")
    oXL.Workbooks.Open (sXclFilePath)
    oXL.Application.ErrorCheck
 
    Set oXL = Nothing

Here's my Excel code:
Code:
Public Sub ErrorCheck()
 
    MsgBox "Inside Excel function."
    'Supposedly some error checking...
 
End Sub

The contents of the ErrorCheck function (in Excel) is just the MsgBox for testing. But my code above displays this error:
"Object doesn't support this property or method"

What's wrong with my code above?
How to call Excel customed function within MS Access?


-= keirnus =-
 
Last edited:
nevermind...i thought it will take me long time to figure it out... :D

sharing my knowledge:

Code:
    With oXL
        .Workbooks.Open (sXclFilePath)
        .Workbooks(sXclFilePath).RunAutoMacros (xlAutoOpen)
        .Application.Run ("ErrorCheck")
        .Workbooks.Close
    End With

:cool:
 

Users who are viewing this thread

Back
Top Bottom