Use Excel Worksheet Function COUPPCD and COUPNCD

Posted on 2005-04-06
Last Modified: 2012-05-05
I want use Excel worksheet functions COUPPCD and COUPNCD in my VBA code for Access. I have created the Excel object and use its "worksheetfunction" method to call COUPPCD and COUPNCD. But it fails. Can someone help me to solve the problem? Or if there is equivalent functions in VBA or Access?
Question by:StanleyLMW
    LVL 46

    Expert Comment

    Make sure you have a reference to the atpvbaen.xla something like this:

     Set XlsObj = New Excel.Application
       XlsObj.Workbooks.Open (XlsObj.Application.librarypath & _
          ' Runs the AutoOpen macro in the add-in
      XlsObj.Workbooks("atpvbaen.xla").RunAutoMacros (1)

    Good Luck!


    Author Comment

    After using the code you have provided, it still doesn't work. VBA reports that the object (which is Excel object) does not support the method COUPPCD or COUPNCD
    LVL 46

    Accepted Solution

    In your function after the above code try something like

    MyFunc  = XlsObj.Application.Run("atpvbaen.xla!COUPPCD ", Param1, Param2,Param3,Param4)

    Makesure that the params are of the right data type

    Author Comment

    great it is done
    LVL 46

    Expert Comment

    Glad to help!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
    A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
    With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
    With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now