I have written a macro that loads data from several dbf files into different sheets of a calc spread sheet. The macro works very well except for one problem, it does not see recent changes in the dbf files. The datasource is an odb file pointing to a directory with a varying number of dbf tables which are loaded by another process. The odb file only see changes when I manually refresh tables (Base View->Refresh tables) using Libreoffice base.
I tried to record a macro in base but the record macro option is grey.
Does anybody know how to refresh tables with a macro?
Here is a little more information about my macro. Here is the code I use to connect to the odb file:
Dim DatabaseContext as Object
Dim Datasource As Object
Dim Connecticus As Object
Dim Stm as Object
Dim Resultset as object
DatabaseContext = createUnoService("com.sun.star.sdb.DatabaseContext")
Datasource = DatabaseContext.getByName("catgamedata")
Connection = Datasource.GetConnection("","")
I was hoping there was some method for the DatabaseContext that would force the update.
I tried adding your (Ratslinger) code and it was working great until I closed Base leaving only Calc running. Then it crashed on the “doc =”, the error “Object variable not set”. So I tried a few variations:
test_doc = Connection.Parent
test_doc = Connection.Parent.DatabaseDocument
test_doc = Connection.Parent.DatabaseDocument.CurrentController
The first and second left “test_doc = com.sun.star.comp.dba.ODatabaseSource”. The third one left “test_doc = Null”. It seems that without Base running there is no CurrentController.
Is it possible to accomplish the same update of the database odb some other way? Is there a method (function, procedure, whatever they call object attached routines in this language.) that will force a refresh?
I found this command:
docmd.runCommand("DBRefreshTables")
As usual I could not find any information about what “docmd” and “DBRefreshTables” require. Does anyone have any ideas?