Hello ebosysindia and welcome to the Java Programming Forums :D
I think your best option here would be to use a Visual Basic Script to run the Access Macro and execute this script from within your Java application.
I have done some research and I think you can use this VBS. It's untested though.
Obviousally change 'mydatabase.mdb' and 'macroname' to be correct. Save in notepad to C:\WINDOWS\system32 as runmacro.vbs
Then you can use this Java code to run the script:
Code :
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
public class AccessMacro {
private static void createAndShowGUI(){
JFrame frame1 = new JFrame("Run Macro");
frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JButton button = new JButton(" >> JavaProgrammingForums.com <<");
// Add action listener to button
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// Execute when button is pressed
try{
Runtime.getRuntime().exec("cmd /c start runmacro.vbs");
}catch(Exception a){
System.out.println("Problem opening runmacro script!");
}
}
});
frame1.getContentPane().add(button);
frame1.pack();
frame1.setVisible(true);
}
public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}
}
Let me know what happens!