XLL file and VB6 Applications
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 14 of 14

Thread: XLL file and VB6 Applications

  1. #1
    Join Date
    May 2009
    Posts
    32

    XLL file and VB6 Applications

    I have an .XLL file from Excel that contains a function that I would like to use in a VB6 program.

    While I do not know what the function does from within (blackbox) and do not really care, I do know the parameters it takes and what type it returns.

    So the only thing I need is to know if I can use an XLL function from within VB6, and if so, how?

    Thank you.

  2. #2
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    15,002

    Re: XLL file and VB6 Applications

    Use VBA, but users MUST have Office installed, otherwise, it will fail. You are not allowed to distribute any OFFICE files.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    May 2009
    Posts
    32

    Re: XLL file and VB6 Applications

    So does that mean that you cannot call a XLL function from within VB6?

    I have no desire to distribute office files. This is for my own personal use.

    But I would like to use the function within VB6 app, not a VBA program.

    And yes, I have office installed.

  4. #4
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    15,002

    Re: XLL file and VB6 Applications

    Then, the easiest way is to write a MACRO (or just RECORD it). That will give you the VBA source code, which can usually be adapted to VB6 pretty easily.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  5. #5
    Join Date
    May 2009
    Posts
    32

    Re: XLL file and VB6 Applications

    Thanks for your reply.

    Unfortunately, recording a Macro is not going to show how to call a function from within a XLL file inside VB6 code.

  6. #6
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    15,002

    Re: XLL file and VB6 Applications

    Take a look at this. Also, there's an AUTOSTART macro that will run a macro automatically
    Attached Files Attached Files
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  7. #7
    Join Date
    May 2009
    Posts
    32

    Re: XLL file and VB6 Applications

    First, I would like to say thank you for taking time on this. Very generous of you. :-)

    Unfortunately, we have not been addressing the problem I am asking about.

    In the example code you provided, there are NO REFERENCES to any functions within a .XLL file.

    Please understand, I am NOT trying to control Excel from VB6. I do not want to write or read anything from an Excel Worksheet.

    What I want to do is to use a .XLL file that contains FUNCTIONS normally used within Excel. I want to use them in VB6, just like if it were a .DLL file.

    Stand-alone VB6 app using a function compiled in a XLL file.

    I need to know if this is possible, and if so, how?

    Again, your code only manipulates Excel worksheets to do this or that, but does NOT use any functions from a XLL file.

    Thanks again.


  8. #8
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    15,002

    Re: XLL file and VB6 Applications

    Well, if a MACRO were to READ YOUR PARAMETERS, and EXECUTE whenever it was opened, your program would WRITE THE PARAMETERS, and start Excel with the worksheet set to open and execute AUTOSTART
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  9. #9
    Join Date
    May 2009
    Posts
    32

    Re: XLL file and VB6 Applications

    Yes, but I do not want to open Excel, or a spreadsheet.
    I do not wish to use Excel at all.

    I can use the functions within xlMath.xll in my Excel programs by declaring xlMath.xll within a VBA program.

    I only want to use a .XLL function in VB6 to create a Stand-alone VB app.

    Public Declare Function XLLFunc Lib "xlMath.xll" (ByVal emb As Integer, ByVal Data As Single, ByVal iFirst As Integer, ByVal iLast As Integer, Optional flgdt As Boolean, Optional flgstd As Boolean)

    If it were a DLL, it would be something like the above.

    I'm only trying to find out if I can do the same with a XLL, and if so, how.

    No Excel. No Worksheets.

    Thanks.

  10. #10
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    4,860

    Re: XLL file and VB6 Applications

    What kind of functions are we talking about? I assume they are generic with no excel requirement.
    I suppose you do not have the code for this xll file right?
    Always use [code][/code] tags when posting code.

  11. #11
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    4,860

    Re: XLL file and VB6 Applications

    Something I found on the net, may help?

    An xll is just a dll. If you know the signature of the function you want to call, you can call it just like any other function. If you don't know the signature but can load the add-in in Excel, there is a way to get Excel to tell you the signature.

    Automation only works if you are running Excel. There is no need for that once you know the signature.

    More info that may be of some help.

    http://www.cpearson.com/excel/AutomationAddIns.aspx
    Last edited by DataMiser; September 29th, 2011 at 03:06 PM.
    Always use [code][/code] tags when posting code.

  12. #12
    Join Date
    May 2009
    Posts
    32

    Re: XLL file and VB6 Applications

    Thanks.

    I will check that out.

    But yes, I know the signature. I guess that means if I know what parameters it takes and what it returns. This I know.

    I don't know if they have Excel requirements. I'm hoping they do not. As you just found, they should be just like DLL's. But I cannot seem to get the DECLARE to work with it like a DLL. So I'm thinking there must be something else to it.


  13. #13
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    15,002

    Re: XLL file and VB6 Applications

    Except that they might be compiled in C++ using POINTERS, which VB6 does not have the ability to utilize...
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  14. #14
    Join Date
    May 2009
    Posts
    32

    Re: XLL file and VB6 Applications

    Yep. Kinda hitting a brick wall on this.

    Thanks.

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center