Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Invoke an Access VBA public function from Java 2

Status
Not open for further replies.

Arkhron

Technical User
Sep 1, 2003
8
0
0
CO
I'm a ultranewbie in java programming (and in english writing, sorry).

I'm connected to an Access database with a JDBC:ODBC driver. Something like this:

Code:
public class PruebaAccess {
	
	private Connection con;
	private String Database;
		
		
	public PruebaAccess(String Database) {
		this.Database = Database;
		}
        
        public void escribir(){
	
        //La conexion arranca en null
	
         	con = null;

		try {

		// Registrar el driver
		Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

		// Crear la conexion
		con = DriverManager.getConnection("jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb)};DBQ="+this.Database,"","");

				
		} catch (SQLException sqle) {
        ........ etc .......
        }
        ........ etc .......
}

But I need to invoke an Access VBA public function from this method. I have no idea about how to do that (if is possible).

Or maybe trying to run an Access Macro from Java, because if I can run a macro, can run a function.

Somebody can help?
Thanks
 
Ok, here I am again.

My boss wrote a procedure that can be useful. It is not exactly that I was looking for, but is a solution. Is using a "wsf" script in order to call different applications from it. This way I can execute Eclipse, to run mi java code; execute MS Access, to run a macro with the function needed, and again execute my Java from Eclipse.

Code:
<job>
<script id="GenerarCensoTxt" language="vbscript">
        Dim WSHShell
        Set WSHShell = WScript.CreateObject("WScript.Shell")
        intReturn = WshShell.Run("C:\j2sdk1.4.2_03\jre\bin\java.exe -cp c:\eclipse\workspace\CCBDiaria RunCESCE", 1, TRUE)
        WSHShell.popup "Terminada la generacion", , "Censo.txt"
   </script>
<script id="RevisarNormalizar" language="vbscript">
		
		'Automatizar access Para normalizar las nuevas
		Dim acApp
		
		'Automatizar Access
		Set acApp = WScript.CreateObject("Access.Application")
		acApp.Visible = True
		acApp.OpenCurrentDatabase "c:\nodo\NuevasCCB.mdb"
		
		acApp.DoCmd.RunMacro "1Revisar Normalizacion"
		
   </script>

<script id="GenerarCensoAProc" language="vbscript">
        Dim WSHShell, FSO
        Set WSHShell = WScript.CreateObject("WScript.Shell")
        WSHShell.popup "Solo Pulse Aceptar cuando acabe de revisar la normalizacion", , "Generando censo a procesar"

		'Automatizar access Para normalizar las nuevas
		Dim acApp
		
		'Automatizar Access
		Set acApp = WScript.CreateObject("Access.Application")
		acApp.Visible = True
		acApp.OpenCurrentDatabase "c:\nodo\NuevasCCB.mdb"
		
		acApp.DoCmd.RunMacro "2Generar  censoAProc"
        acApp.quit
        intReturn = WshShell.Run("C:\TTERMPRO\ttssh.exe 192.168.73.101 /ssh /m=censo.ttl", 1, TRUE)
   </script>
<script id="SubirCensoAproc" language="vbscript">
        Dim WSHShell, FSO
        Set WSHShell = WScript.CreateObject("WScript.Shell")
        intReturn = WshShell.Run("C:\TTERMPRO\ttssh.exe 192.168.73.99 /ssh /m=perm.ttl", 1, TRUE)	
</script>
<script id="PegarBalances" language="vbscript">
        Dim WSHShell, FSO
        Set WSHShell = WScript.CreateObject("WScript.Shell")
        intReturn = WshShell.Run("C:\j2sdk1.4.2_03\jre\bin\java.exe -cp c:\eclipse\workspace\BaldeZipsCCB RunBaldeZips", 1, TRUE)
        WSHShell.popup "Terminados los balances", , "NuevasCCB"

</script>
</job>

Hope will be useful for someone.

Again thanks to stefanwagner and dbleyl, and again, sorry about my English.



LEY DE EDWARDS SOBRE EL ESFUERZO/TIEMPO.
Esfuerzo x Tiempo = Constante.
Dado un tiempo inicial grande para hacer algo, el esfuerzo inicial será pequeño.
A medida que el tiempo se aproxima a cero, el esfuerzo tiende a infinito.

-"Murphy fue un optimista"-
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top