I am starting to use LibreOffice, and I have a problem. I can’t run my macros as I could in MS Word.
I got an error when I am trying to use my code, that works without any problems in MS Word.
My code:
Sub SKABELON_MEMORADIUM()
Dim Stry As Range, TOC As TableOfContents
Dim StrPath As String, StrName As String, StrName1 As String
'Set Default save path
StrPath = "C:\Users\" & Environ("UserName") & "\OneDrive\6. MEMORADIUM\"
With ActiveDocument
Application.ScreenUpdating = False
For Each Stry In .StoryRanges
Stry.Fields.Update 'UPDATE FIELDS IN ALL STORY RANGES
Next
For Each TOC In .TablesOfContents
TOC.Update 'UPDATE TABLES OF CONTENTS
Next
Application.ScreenUpdating = True
'Check whether the filename contains 'MEMORADIUM - '
'If not, that's what we need to save it with
If InStr(.Name, "MEMORADIUM - ") = 0 Then
'Get the contents of the EMNE content control so we can add it to the filename
StrName = .SelectContentControlsByTitle("EMNE")(1).Range.Text
StrName1 = .SelectContentControlsByTitle("ID")(1).Range.Text
'Display the FileSaveAs dialogue
With Dialogs(wdDialogFileSaveAs)
.Name = StrPath & "ID" & " " & StrName1 & " " & "MEMORADIUM - " & StrName
.Format = wdFormatXMLDocument
.Show
End With
Else
.Save
End If
End With
Dim oStory As Object
Dim oToc As Object
'EXIT IF NO DOCUMENT IS OPEN
If Documents.Count = 0 Then Exit Sub
Application.ScreenUpdating = False
For Each oStory In ActiveDocument.StoryRanges
oStory.Fields.Update 'UPDATE FIELDS IN ALL STORIES
Next oStory
For Each oToc In ActiveDocument.TablesOfContents
oToc.Update 'UPDATE TABLE OF CONTENTS
Next oToc
Application.ScreenUpdating = True
End Sub