Macro mysteriously stopped working

I have two calc macros with similar code structure that are now both generating “Basic runtime error Variable not defined”. I’m wondering whether this might have happened after a LO update? I can’t think of any other reason, since nothing as far as I can recall has changed. I don’t remember whether my LO has updated recently (or whether it does so automatically).

Here’s the code (the error occurs on the last line shown):

Dim oDoc As Object
Dim sUrl As String
Dim oTargetDoc As Object

oTargetDoc= ThisComponent Rem TargetDoc is the spreadsheet you are working from

Dim Prop(0) as New com.sun.star.beans.PropertyValue

Prop(0).name=“FilterName”
Prop(0).value=“MS Excel 97”
sUrl = convertToURL(“c:\Backup\oc\invts\portfolio.xls”)

if fileExists(sUrl) then
oDoc = stardesktop.LoadComponentFromURL(sUrl, “_blank”,0, Prop())
else
msgbox “Not found”
end if

Rem copy the relevant data up to row 100 and paste it into target doc
oSheet = oDoc.Sheets.getByName(“trades”) Rem oDoc is portfolio.xls

Anybody had a similar experience/ guess what might be happening here?

There is no sheet with name »trades« inside …portfolio.xls ?!

Thanks for the suggestion, but yes, there is a sheet with that name. The same thing happened in a very similar macro, also where the sheet name is valid. As I mentioned, the macro has not changed since I last used it successfully, and nor has the structure of the spreadsheet on which it works.

Missing Dim oSheet As Object

Thanks. Yes, I had tried that. It seems there are several instances of undefined variables, although I still haven’t managed to fix the whole subroutine. What I don’t understand is what changed? I’ve used this macro probably two or three times a week for a couple of years, and this suddenly started happening. Weird.
I looked at the program files and found an update log for 10/23/25. I suspect that is where the change happened. I’m wondering if I should file a bug report?