Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 11-15-2025, 09:14 AM
grumblid grumblid is offline Can anyone convert Word macros into LibreOffice ones? Windows 10 Can anyone convert Word macros into LibreOffice ones? Office 2003
Novice
Can anyone convert Word macros into LibreOffice ones?
 
Join Date: Jul 2016
Posts: 28
grumblid is on a distinguished road
Question Can anyone convert Word macros into LibreOffice ones?

So years ago I was helped by three legends on this forum:
@Charles Kenyon
@Guessed
@gmayor

They helped me by making macros that I had (and still have) no idea how to make, and I am grateful for them and all the time those macros have saved me in my creative writing projects. Well, now I’m in a similar situation as before.

While I don’t want to part ways with my beloved Word 2003, I know I can't keep using it forever. So I have to switch over to something more future-proof, and I've chosen LibreOffice. The problem is the Word macros won’t work on LO because they have different coding languages. I actually posted in the LibreOffice forums about it, but I figured I’d ask here too just in case someone can help here before someone can help over there.

My question is "Are there any LibreOffice macro experts in the house?"


If not, that’s okay. I’m literally on a Word forum, which has nothing to do with LibreOffice so that's my own dang fault.

If the answer is yes, I have another question for ya: Are you badass enough to convert these Word macros into LO ones??
(Because I can’t. I have no idea what I’m doing over here, haha.)

So here is the first Word macro, which makes so you can search a keyword and it’ll send all paragraphs containing those keywords to a new document that opens up:

Code:
Sub TheNewMagicTimeSaver()
  Dim oDoc As Document
  Dim oRng As Range
  Dim strKeyWord As String
  strKeyWord = InputBox("What are you looking for?")
  If strKeyWord = "" Then GoTo lbl_Exit
  Set oRng = ActiveDocument.Range
  Set oDoc = Documents.Add
  With oRng.Find
    Do While .Execute(FindText:=strKeyWord, MatchCase:=False, MatchWholeWord:=True)
      oDoc.Range.InsertAfter oRng.Paragraphs(1).Range.FormattedText
      oDoc.Range.InsertParagraphAfter
      oRng.Paragraphs(1).Range.Delete
      oRng.Collapse 0
    Loop
  End With
  oDoc.Range.ParagraphFormat.SpaceBefore = 0
  oDoc.Range.ParagraphFormat.SpaceAfter = 0
lbl_Exit:
  Exit Sub
End Sub
And here is the second Word macro, which takes all paragraphs and automatically arranges them from biggest to smallest.

Code:
Sub SortParasBySize()
  Dim aRng As Range, aTable As Table, aRow As Row
  ActiveWindow.View = wdNormalView
  With ActiveDocument.Range.Find  'Do Find and Replace for separators
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "^p"
    .Replacement.Text = "zx"
    .Forward = True
    .Wrap = wdFindContinue
    .Format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    .Execute Replace:=wdReplaceAll
    .Text = "zxzx"
    .Replacement.Text = "^p"
    .Execute Replace:=wdReplaceAll
    ActiveDocument.Range.ConvertToTable Separator:=wdSeparateByParagraphs, NumColumns:=1
    .Text = "zx"
    .Replacement.Text = "^p"
    .Execute Replace:=wdReplaceAll
  End With
  Set aTable = ActiveDocument.Tables(1)
  aTable.Columns.Add BeforeColumn:=aTable.Columns(1)
  For Each aRow In aTable.Rows
    aRow.Cells(1).Range.Text = Len(aRow.Cells(2).Range.Text)
  Next aRow
  aTable.Rows.Add BeforeRow:=aTable.Rows(1)
  aTable.SortDescending
  aTable.Columns(1).Delete
  aTable.Columns.Add    'insert empty column to reinstate extra paras between sections
  aTable.Rows(1).Delete
  aTable.ConvertToText Separator:=wdSeparateByParagraphs
End Sub
Thank you for any help, and I apologize for still not knowing how this stuff works. I am but a simple man.

Last edited by grumblid; 11-16-2025 at 04:14 AM.
Reply With Quote
 

Tags
libre office, macro, word 2003



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can anyone convert Word macros into LibreOffice ones? Make Word look like LibreOffice? wrod Word 2 01-17-2023 09:12 AM
Word Refuses to Allow Macros, even when All Macros Enabled devlon Word VBA 3 10-04-2022 02:15 PM
Security warning bar for macros, without any macros ACA Word 1 10-04-2020 11:32 AM
Can anyone convert Word macros into LibreOffice ones? How to automatically enable the macros upon opening a file with macros? laurieli Office 7 01-17-2016 08:56 AM
Can anyone convert Word macros into LibreOffice ones? Macros to convert text to Table josia Word VBA 3 08-28-2015 09:11 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:49 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft