Just to prime the pump so to speak.
Let me mention that something like this should possible with an
extension, nowadays - all of the the following works completely via UNO API:
1. Adding menu items to applications

Using the BasicAddonBuilder.oxt this is simple - note there is a bug with adding toolbars, but it is easy to work around.

2. opening the file/folder picker for browsing for .dbf files
A quick copy and change to some code I already use:

function babs_fnGetTableNames( optional inPath as string) as string
   dim fileExt(1,1) as string
   fileExt(0,0) = "dBase *.dbf"
   fileExt(0,1) = "*.dbf"
' fileExt(1,0) = "MS Access *.mdb; *.accdb"
'    fileExt(1,1) = "*.mdb; *.accdb"
'
'

   if not ismissing( inPath ) then
       babs_fnGetTableNames =  babs_GetFileName( fileExt(), inPath )
   else
       babs_fnGetTableNames =  babs_GetFileName( fileExt() )
   end if
end function


function babs_GetFileName( Filternames(), optional inPath as string) as string
Dim oFileDialog as Object
Dim iAccept as Integer
Dim sPath as String
Dim InitPath as String
Dim RefControlName as String
Dim oUcb as object

   'Note: The following services have to be called in the following order
   ' because otherwise Basic does not remove the FileDialog Service ????
   oFileDialog = CreateUnoService("com.sun.star.ui.dialogs.FilePicker")
   oUcb = createUnoService("com.sun.star.ucb.SimpleFileAccess")
   babs_AddFiltersToDialog(FilterNames(), oFileDialog)
   if isMissing( inPath ) then
       InitPath = GetSimplePathSetting("Work")
   else
       InitPath = ConvertToURL( inPath )
   End If
If oUcb.Exists(InitPath) Then
       oFileDialog.SetDisplayDirectory(InitPath)
   End If
   oFileDialog.Title = "Import Table"
   iAccept = oFileDialog.Execute()
If iAccept = 1 Then
       sPath = oFileDialog.Files(0)
       If oUcb.Exists(sPath) Then
           babs_GetFileName = sPath
else babs_GetFileName = ""
       End If
   else
       babs_GetFileName = ""
   End If
   oFileDialog.Dispose()
   ' oUcb.Dispose() ' another one not to dispose of...??
End function

Sub babs_AddFiltersToDialog(FilterNames() as String, oDialog as Object)
Dim i as Integer
Dim MaxIndex as Integer
Dim ViewFiltername as String
   MaxIndex = Ubound(FilterNames(), 1)
   For i = 0 To MaxIndex
       oDialog.AppendFilter(FilterNames(i,0), FilterNames(i,1))
   Next i
   oDialog.SetCurrentFilter(FilterNames(0,0)
End Sub

'****************

Function GetSimplePathSetting(sPathType as String) as String
Dim sPath as String
Dim oPathSettings as Object
oPathSettings = createUnoService("com.sun.star.util.PathSettings")
    GetSimplePathSetting = oPathSettings.getPropertyValue(sPathType)

End Function

'*****************

You can just call the above with

Sub Main
   babs_fnGetTableNames()
End Sub

and it opens in the current working directory.

3. creating a (temporary) .odb file to connect to the dBase files

BRB

4. triggering the "Copy Table" wizard



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to