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

  • SEARCH
  • Home
  • 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 6095745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:50:49+00:00 2026-05-23T12:50:49+00:00

Is there a library in Java, that allows adding pre-written VBA code into a

  • 0

Is there a library in Java, that allows adding pre-written VBA code into a document ?
I have a lot of files, and I need the same code to be inserted in all of the documents.

I have a test with checkboxes, I gave the test to the people who are supposed to answer that, and later the idea of calculating the scores came up to mind and wrote a little of VBA code, now I need to include that on all the test documents once I get them back.

I’m looking for a Java library, but if there is a simpler way to do that in Delphi or VB, that would be great !

Thanks in advance,
Regards, Taha

  • 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-23T12:50:50+00:00Added an answer on May 23, 2026 at 12:50 pm

    I’ve injected a macro into an existing docx using docx4j (Java), and via a VSTO Word add-in (C#, OpenXML SDK).

    Here is the docx4j code (not tested recently):

    // Add our macro to the document
    
    // Get vbaProject.bin, and attach it to wordDocumentPart
    
    java.io.InputStream is = ResourceUtils.getResource("docm/vbaProject.bin");                  
    VbaProjectBinaryPart vbaProject = new VbaProjectBinaryPart();
    vbaProject.setBinaryData(is);
    wordDocumentPart.addTargetPart(vbaProject);
    
    // Get /word/vbaData.xml, and attach it to vbaProject
    VbaDataPart vbaData = new VbaDataPart();
    java.io.InputStream is2 = ResourceUtils.getResource("docm/vbaData.xml");                    
    vbaData.setDocument( is2 );
    
    vbaProject.addTargetPart( vbaData);     
    
    // Change the Word document's content type!
    wordDocumentPart.setContentType( new ContentType(
            ContentTypes.WORDPROCESSINGML_DOCUMENT_MACROENABLED ) );
    ContentTypeManager ctm = p.getContentTypeManager();
    PartName partName = wordDocumentPart.getPartName();
    
    ctm.removeContentType( partName  );
    ctm.addOverrideContentType( new java.net.URI("/word/document.xml"), 
            ContentTypes.WORDPROCESSINGML_DOCUMENT_MACROENABLED);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any java library that allows to export LaTeX document to other formats
Does Java have (or is there a library available) that allows me to have
Is there an existing library that allows me to annotate a Java method as
Is there any Java library that supports hierarchical column? For example (the first three
Is there a public library for Java (free) that can be used to display
is there an algorithm available for Java that will allow me to keep adding
Is there any free java library which I can use to convert string in
Is there an existing application or library in Java which will allow me to
Is there a library that would allow me to send and receive data on
Is there a library in python that works like this? >>> resolvePath(http://www.asite.com/folder/currentpage.html, anotherpage.html) 'http://www.asite.com/folder/anotherpage.html'

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.