Hi Tamblyne,
Tamblyne escribió:
Drew Jensen wrote:
Hi Tamblyne
Just to let you know I sent email to the other fellow working on a
genealogy database but have not heard anything back yet.
Thanks, Drew -- I look forward to learning how he's approaching it, and
if he needs any help.
Also, it sounds like Ariel's example covered what you needed or is
there still the issue of launching the external programs?
It does look like it is exactly what I need.
As far as launching the external programs, I did find some macros on the
forum to do that, but you have to specify each program. So if you have
the time, I'd love some help with a macro that will launch the default
program based on the file extension.
in theory the following should work:
'*******************************************************************
Option Explicit
'Executes an abitrary system command.
' @param:
' aCommand: Specifies the command to execute.
' This may be an executable file or a document
which is registered
' with an application on a specific platform, so
that the platform
' knows what application to launch for that
document.
' If the command specifies a path to an
executable, etc,
' this has to be a system specific path.
' aParameter Specifies a list of space separated parameters.
' The method does not validate the given
parameters,
' but only passes it as a parameter to the
specified command.
' nFlags Specifies different flags to control the execution of
this
method,
' for example, avoid showing system error
messages, in case of
failures, etc.
' It's one of
com.sun.star.system.SystemShellExecuteFlags
' [NOTE: here is OPTIONAL and defaults to
SystemShellExecuteFlags.NO_SYSTEM_ERROR_MESSAGE]
Function ExecuteSystemCommand(_
aCommand as
String, _
aParameter as
String, _
Optional nFlags
as Long) as Boolean
On Error GoTo ExecuteSystemCommand_EH
Dim bExecuted as Boolean : bExecuted = False
Dim oSystemShellExecute as Object
oSystemShellExecute =
createUnoService("com.sun.star.system.SystemShellExecute")
If IsMissing(nFlags) Then
nFlags =
com.sun.star.system.SystemShellExecuteFlags.NO_SYSTEM_ERROR_MESSAGE
End If
oSystemShellExecute.execute( aCommand, aParameter, nFlags)
bExecuted = True
ExecuteSystemCommand_EH:
ExecuteSystemCommand = bExecuted
End Function
'*******************************************************************
You may use it like this:
Dim bExecuted as Boolean
bExecuted = ExecuteSystemCommand("/home/ariel/Documents/test.pdf", "")
But I say in "theory" because it is in a very buggy state, at least on
Linux: it says that "If the command specifies a path to an executable,
etc, this has to be a system specific path.", but the above is a system
path in Linux ("/home/ariel/Documents/test.pdf"), but throws an
exception on SuSe and Mandriva with the KDE (didn't try Gnome)
To avoid the exception I must convert it to URL, with the following result:
* on SuSe, it opens the default application
* on Mandriva, it opens *first* Konqueror, and only *then* the default
application
I don't remember what happens on Windows, you will have to try it.
Regards
Ariel
--
Ariel Constenla-Haile
La Plata, Argentina
[EMAIL PROTECTED]
[EMAIL PROTECTED]
http://www.ArielConstenlaHaile.com.ar/ooo/
"Aus der Kriegsschule des Lebens
- Was mich nicht umbringt,
macht mich härter."
Nietzsche Götzendämmerung, Sprüche und Pfeile, 8.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]