Ask Your Question
1

Executing macro on server without GUI [closed]

asked 2013-11-06 11:59:28 +0100

Michael Okuntsov gravatar image

updated 2013-11-06 14:31:39 +0100

Hello,

sometimes I need to execute the macro in the document on a remote ssh server. Here is the command I use:

soffice --headless macro:///Standard.Module1.select_out_of_range tables.xls

It just hangs until I press ctrl+c. Is there the way to do it? Thanks. (When this macro is running on the local machine, it runs without problems.)

Here is a macro:

sub select_out_of_range
     Dim oDescriptor 'The search descriptor
      Dim oFound as Object 'The found range
      Dim oFoundAll as Object 'The found range
      dim oDoc as Object
      dim oSheet as Object
      oDoc=ThisComponent
      oSheet = oDoc.Sheets.getByIndex(0)
      oDescriptor  = oSheet.createSearchDescriptor()
      oDescriptor.SearchString = "^&(.*)"
    '  oDescriptor.ReplaceString="$1"
      oDescriptor.SearchRegularExpression=True
      oFoundAll = oSheet.FindAll(oDescriptor)
      if not (oFoundAll is Nothing) then
              For n = 0 to oFoundAll.getCount()-1
                oFound = oFoundAll.getByIndex(n)
                oFound.CellBackColor = 12632256
              Next
              Dim oReplace as Object
              oReplace=oSheet.CreateReplaceDescriptor()
              oReplace.SearchString = "^&(.*)"
              oReplace.ReplaceString="$1"
              oReplace.SearchRegularExpression=True
              oSheet.ReplaceAll(oReplace)
      endif
      oColumns = oSheet.getColumns()
      iLastColumn = 30 'last column to be applied with OptimalWidth

      for iIndex = 0 to iLastColumn
            oColumn = oColumns.getByIndex(iIndex)
            oColumn.OptimalWidth = true
      next iIndex
      oSheet.Columns(0).Width=4000
      oDoc.store()
    '  ThisComponent.close(True)
    '  stardesktop.terminate

    end sub
edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by Alex Kemp
close date 2015-11-13 05:52:11.415526

1 Answer

Sort by » oldest newest most voted
2

answered 2013-11-06 16:00:00 +0100

Michael Okuntsov gravatar image

Found solution:

libreoffice --invisible --nofirststartwizard --headless --norestore tables.xls "macro:///Standard.Module1.select_out_of_range"

The document in the macro should be closed at the end.

edit flag offensive delete link more

Comments

For python macros, see this .

sup gravatar imagesup ( 2014-08-26 12:23:45 +0100 )edit

Question Tools

1 follower

Stats

Asked: 2013-11-06 11:59:28 +0100

Seen: 1,528 times

Last updated: Nov 06 '13