This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

how can I create an "edit online " sharable log document with a macro to print date and time ?

Is this doable? Example image attached.

Parents
  • Verified Answer

    +1  

    I think I have managed to do what you wish to achieve, there was not too much detail in your request. Have a look at the video filr.microfocus.com/.../macro.mp4

    Write a macro to do what you wish, I wrote (Well ChatGPT did most of it, but made a number of mistakes) a macro that found the first table in the document, went down the comments column until it found a blank cell, then inserted the current date in the date column.  I found the word macro did not work in CE so I ended up doing it in LibreOffice.  Do edit the macro as necessary.  

    Sub FillDate()

                    Dim oDoc As Object

                    Dim oTable As Object

                    Dim i As Integer

                    ' Get the document and sheet

                    oDoc = ThisComponent

     

                  oTables = ThisComponent.getTextTables()

                  oTable = oTables.getByName("Table1")

     

                    ' Loop through the rows of the table

                    For i = 0 To  oTable.Rows.Count - 1

                                    ' Check if column B is blank

                                   

                                    If oTable.getCellByPosition(1, i).getString() = "" Then

                                                    ' Fill in the date in column A

                                                    oTable.getCellByPosition(0, i).setstring(Format( Now, "DD\/MM\/YYYY"))

                                                    ' Exit the loop

                                                    Exit For

                                    End If

                    Next i

    End Sub

     

    Set the macro to auto run when opening the document.

    Enable Macros in Content Editor as per the Collabora documentation at https://www.collaboraoffice.com/integration/how-to-use-and-manage-macros-in-collabora-online/ For security reasons I left the run macro prompt in, you may wish to go for a security level of 0 so there is no prompt.

    When I open the document the current date is inserted in the date column,

  • 0 in reply to   

    Oh my! Thank you Robin, I will test this tonight,

Reply Children
No Data