Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6201025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:28:40+00:00 2026-05-24T04:28:40+00:00

I have an Excel file with a large set of VBA code. There are

  • 0

I have an Excel file with a large set of VBA code. There are 4 public subroutines that take no parameters that can be called by the user when the document is opened in Excel, these manipulate the data in the various sheets as needed. We have a large Java application that we would like to interact with this document by calling the Macros from the Java environment. The point is that we only have to write the VBA code once and then Java can call it for execution. Furthermore, we want to assume that the user of the Java application does not necessarily have immediate access to Excel, but is operating on a Windows machine. How should one go about doing this?

Do we compile the VBA code into a DLL, and call it from within Java? How do you compile the DLL, does that require the use of Visual Studio? How do we call the DLL from Java? Should we try some sort of COM object?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T04:28:40+00:00Added an answer on May 24, 2026 at 4:28 am

    I basically see three options for calling VBA code in Excel from a Java application:

    1. Java COM Bridge: There are several tools available that allow you to call COM or COM Automation components from Java. Excel is such a component. I know of Jacob and JCom, but there might more such tools available.

    2. Java / VBScript / COM Automation: Since you obviously don’t need to pass data to the VBA code, the simplest solution is probably to write a VBScript that starts Excel, opens the document, calls the macro and closes Excel. This script is started from Java with Runtime.getRuntime().exec("cmd /c start script.vbs");

    3. JNI: You could write a specific DLL for your applications. It implements the JNI interface so it can be called from Java. And its implementation uses COM calls to work with Excel. Such a DLL is best written with VisualStudio and it’s support for C++ to call COM objects.

    Whatever your solution will be, you basically want to execute the following commands on Excel automation interface (sample in VBScript):

    Dim xl
    Set xl = CreateObject("Excel.Application")
    xl.Workbooks.Open ("workbook.xlsx")
    xl.Application.Run "MyMacro"
    xl.Application.Quit
    Set xl = Nothing 
    

    You cannot compile VBA code into a DLL. There exists no tool for that (in contrast to the full Visual Basic).

    I hope this answer is helpful even though I didn’t understand what you mean by: “we want to assume that the user of the Java application does not necessarily have immediate access to Excel, but is operating on a Windows machine.”

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Excel file that has a bunch of VBA and macro code
I have an Excel file with a large set of data. The built-in graphs
I have a fairly large Excel file. In this file there is a column
I have a long running loop in an unfortunately large excel file that I'm
I have a large collection of data in an excel file (and csv files).
I have an excel file which has more than 65536 rows. However, I can
I have got the following code from here to read an Excel file using
I have some content that i have to render as a excel file in
I have written an Excel VBA macro which imports data from a HTML file
I have long HTTP request ( generating large Excel file - about 60K records

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.