Ask Your Question
0

.bat file opens writer not as excutable file

asked 2018-11-26 12:01:30 +0200

koolninja gravatar image

updated 2018-11-26 18:59:59 +0200

Ratslinger gravatar image

Libreoffice 6.1.3 and this micro used in standalone to open .odt form i am using below micro and insert in event open document to open on load but .bat file opens in writer not as executable file

sub openserver

dim sUrl as string
dim oDoc as object, oDocFrame as object, dispatcher as object
dim PropVal(0) as new com.sun.star.beans.PropertyValue
dim args(0) as new com.sun.star.beans.PropertyValue

sUrl = convertToUrl("C:\Test\server.bat")

oDoc = stardesktop.LoadComponentFromURL(sUrl, "_blank", 0, Array())

oDocFrame = oDoc.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

end sub

please help out

edit retag flag offensive close merge delete

Comments

.bat implies windows. What's the text inside your .bat file?

EasyTrieve gravatar imageEasyTrieve ( 2018-11-27 17:57:24 +0200 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2018-11-26 19:49:00 +0200

Ratslinger gravatar image

Hello,

The file is opened by Writer because it is a basically a text file & you have simply asked that the file be opened with LO.

If you want to execute a process outside of LO you should be using the Shell command. Have tested this (starting HSQLDB server) in Linux Mint (uses .sh not .bat) with the following macro:

Sub Main_Open
    Dim sFileName as String
  Rem This works on Mint 18
    sFileName = "/home/linuxnow/a/hsqldbstart.sh"
    shell "bash -c 'sh " & sFileName & "'"
  Rem Arbitrary amount of time for startup of server - may be OK with less time set
    Wait 5000        '5 seconds'
End Sub

You will most likely want something similar to shut down the server.

edit flag offensive delete link more

Comments

Keep in mind the above Shell command is for Linux. You need to adjust the Shell string for your .bat file processing.

Ratslinger gravatar imageRatslinger ( 2018-11-27 09:00:09 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-11-26 12:01:30 +0200

Seen: 47 times

Last updated: Nov 26 '18