How to open 500+ docs and save as .html

I’m having 500+ .doc files to save as html. i’ve started to write a Macro using bits and pieces found there but what I manage to do is to save 500 times the same document.
Is there anybody clever?
(This is my first ever attempt at writing a Macro and hopefully my last)

Here’s what i painfully wrote:

Sub ExportAllDocsToHTML()
Dim vEnumerate 'Enumeration object
Dim vComp 'Single component
Dim s As String 'Display string
Dim sURL As String 'Document URL
GlobalScope.BasicLibraries.LoadLibrary(“Tools”) ’ Only for GetFileName

vEnumerate = vComps.createEnumeration() '
Do While vEnumerate.hasMoreElements()   'Are there any elements to retrieve?
vComp = vEnumerate.nextElement()
    If HasUnoInterfaces(vComp, "") Then
      sURL = vComp.getURL()
      If sURL = "" Then
        s = s & "<Component With No URL>" & CHR$(10)
            ' function below will convert to htrml
        s = s & FileNameOutOfPath(sURL) & CHR$(10)
       	vComp.close(true) 'close open doc
      End If
    End If
MsgBox s, 0, "Files processed"

End Sub

Function SubSaveasHTML(byval sURL)
if sURL= “” then
MsgBox sURL, 0, “Not valid”
exit function
end if

Dim FileN As String ' URL of target CSV-file
Dim oCurrentController As Object ' Before save - activate sheet sSheetName
Dim storeParms(1) as new 
   GlobalScope.BasicLibraries.LoadLibrary("Tools") ' Only for GetFileName
   FileN = GetFileNameWithoutExtension(sURL) & ".html"
   storeParms(0).Name = "FilterName"
   storeParms(0).Value = "HTML (StarWriter)" 
   storeParms(1).Name = "Overwrite"
   storeParms(1).Value = True 

       ConvertFromUrl(FileN) + """.")

End Function

Any help would be appreciated

Hi @Remi,

I haven’t had a chance to look over your code yet, but would it be possible for you to just do the conversion on the command line? Something like this should work:

soffice --headless --convert-to html:HTML myfile.doc

Or for multiple files in a directory:

soffice --headless --convert-to html:HTML *.doc

For more information about command line conversion, take a look at @jopenid’s answer to this question:

And here’s an example from @w_whalley of iterating over many files using the find command:

@remi – Does my answer work for you?