Macro isnt working on windows

Sup, I wrote a macro that renames an image in a folder, then it link the image again to the register. It is not perfect I know, but its working (partially). The macro looks like this:

Sub RenomearImg(oEvent AS OBJECT)

	DIM forms AS OBJECT
	DIM idfoto AS OBJECT
	DIM idcarro AS OBJECT
	DIM idcarrotext AS STRING
	DIM idfototext AS STRING
	DIM oDoc AS OBJECT
	DIM oForm AS OBJECT
	DIM oField AS OBJECT
	DIM oShell AS OBJECT
	DIM stUrl AS STRING
	DIM stField AS STRING
	DIM arUrl_Start()
	DIM stFieldDif AS STRING
	
	forms = ThisComponent.DrawPage.Forms.getByName("MainForm")
	idcarro = forms.getByName("IDCarro")
	idcarrotext = idcarro.text
	oDoc = thisComponent
	oButton = oEvent.Source.Model
	stImageControl = oButton.Tag
	oForm =  forms.getByName("SubFormFoto")
	oField = oForm.getByName("Foto")
	idfoto = oForm.getByName("IDFoto")
	idfototext = idfoto.text
	stUrl = oField.BoundField.getString
	linkfoto= oForm.getByName("LinkFoto")
	
	IF stUrl <> "" THEN
	
		arUrl_Start = split(oDoc.Parent.Url,right(convertToUrl(oDoc.Parent.Title),len(convertToUrl(oDoc.Parent.Title))-8))
		oShell = createUnoService("com.sun.star.system.SystemShellExecute")
		stField = convertToUrl(arUrl_Start(0) + stUrl)
		tamanho = Len(stField) 
		i=0
		tamanhomenor = tamanho 
		
		Do While i < tamanho 
		
			temp = Mid(stField, tamanhomenor, 1) 
			
			if temp = "/" then 
			
				tocut = tamanho - tamanhomenor 
				cortado= tamanho - tocut
				newtext =  Mid(stField, 1, cortado)
				msgbox(stField)
				Name stField as newtext +"carro" +idcarrotext + "." +"foto"+ idfototext + ".jpg"
				i=tamanho
				
			end if 
			
			tamanhomenor=tamanhomenor-1
			i=i+1
			
		Loop
		
		tamanhourl = Len(stUrl)
		tamanhomenos=tamanhourl
		j=0
		
		do while j < tamanhourl
			
			textcheck = Mid(stUrl, tamanhomenos, 1)
			
			if textcheck="/" then
			
				quantidadecorte=tamanhourl-tamanhomenos
				cortefeito=tamanhourl-quantidadecorte
				textostr=Mid(stUrl, 1, cortefeito)
				linkfoto.BoundField.updateString(textostr +"carro" +idcarrotext + "." +"foto"+ idfototext + ".jpg")
				j=tamanhourl
				
			end if
					
			tamanhomenos=tamanhomenos-1
			j=j+1		
					
		loop

	END IF

END SUB

I apologize because some variables are in english and others in portuguese, but I hope you can understand.
My problem is that this macro isnt working on windows, I tested it on windows 10, but I think it applies to any versions. Apparently, windows treat images linked to LO Base differently than linux, because when Im viewing the image on the image control on linux, I can rename it on the folder, but when I try to do the same on windows, it doesnt let me, I think thats it whats blocking the macro from renaming, but the macro error is that it couldnt find the archive on the folder.
I hope theres a way to solve it

The error:
erro
In english it says: BASIC execution error. Archive not found.

Name stField as newtext +“carro” +idcarrotext + “.” +“foto”+ idfototext + “.jpg” //// It happens on this line.

Show the error and the line where it happens.

The error:
erro
In english it says: BASIC execution error. Archive not found.

Name stField as newtext +“carro” +idcarrotext + “.” +“foto”+ idfototext + “.jpg” //// It happens on this line.

Updated the original post also

Show us the value of this string:

newtext +“carro” +idcarrotext + “.” +“foto”+ idfototext + “.jpg”

Running it on linux this is the value.

image

And on windows 10 this is the value.

print

The macro gets all the files before the picture file, that why linux is different than windows.