Macro Error - Incorrect Property Value on showFileLocationInTitleBar

I have a Macro I copied from another post that when I run manually works just fine but when I try to set up an event to automatically run this macro on a Calc file when the file is finished loading (or on open), I get this error:

Sub showFileLocationInTitleBar(Optional pUrlStyle As Boolean)
Basic Runtime Error
Incorrect Property Value

I have tried setting up an event every way I could find in other posts but still get the error message but can run the macro manually and it works without errors.

What I really want to do is set this up to run on any Calc or Writer file I open and not have to set it up with each file as an event.

Any suggestions? I am on LO 7.6.2.1.

I was able to assign a keyboard shortcut for this macro to make it easier to run. If there is not a way to do what I asked above, is there a way to automatically execute the keyboard short cut when a document finishes loading?

I did install the Java Development kit but that did not fix my original problem.

If you assign any macro to an event, then the macro receives an event, as an argument:

Sub my_macro_in_event(event)

End Sub

but “event” is a structure that will depend on the assigned event. Therefore, it is a mistake to assign it as Boolean

without seeing your code is hard to help, but… you should…

Sun macro_event(event)
    Call howFileLocationInTitleBar()
End Sub

I found this at LO and did not write this, but it does work if I run it manually.

REM ***** BASIC *****

Sub onViewCreated()
showFileLocationInTitleBar(False)
End Sub

Sub onDoumentSavedAs()
showFileLocationInTitleBar(False)
End Sub

Sub showFileLocationInTitleBar(Optional pUrlStyle As Boolean)
If IsMissing(pUrlStyle) Then pUrlStyle = True
url = ThisComponent.URL
If url = “” Then Exit Sub REM The document was not yet stored.
If pUrlStyle Then
pN = Split(url, “://”)(1)
Else
pN = ConvertFromURL(url)
End If
ThisComponent.Title = pN
End Sub