Output to text file

Hi I have these macros which work in Excel, how do i get the to work in libreoffice

Sub SaveScript()

  Dim MyFilePath As String, MyFileName As String
  Dim N As Long, nFirstRow As Long, nLastrow As Long

  MyFilePath = Application.GetSaveAsFilename(InitialFileName:="ScriptName", fileFilter:="Text Files (*.txt), *.txt")


  Set fs = CreateObject("Scripting.FileSystemObject")
  Set a = fs.CreateTextFile(MyFilePath, True)
  nLastrow = Cells(Rows.Count, "E").End(xlUp).Row
  nFirstRow = 1

  For N = nFirstRow To nLastrow
    t = Replace(Cells(N, "E").Text, Chr(10), vbCrLf)
    a.WriteLine (t)
  Next
  a.Close 
End Sub

Sub md5sum()
  Dim r As Range
  Set r = Intersect(ActiveSheet.UsedRange,Range("E:E")).Cells.SpecialCells(xlCellTypeBlanks)
  r(1) = "=""md5sum""&"" ""&B3&B1&B2&"" ""&"">""&"" ""&B3&B1&""-md5.txt"""
End Sub

Sub CallSaveScript()
  Call md5sum
  Call SaveScript
End Sub

You must rewrite it based on the API of the LibreOffice. You can call the API functions from StarBasic or any other supported programming languages.
API: Application Programming Language.

Study Andrew Pitonyak’s free macro programming books.