Im having trouble implementing a rename image macro on windows 10, apparently it opens images on image control of LO Base, differently from linux, because on linux it is possible to rename an image while it is open on Base, but on windows it isnt.
This is the macro Im using:
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)
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 thought of a way to go around this problem, if I can change this macro to make it copy the og image, paste it, rename the copied image, and then delete the og image, the name linked to the DB would be the new one, so it would look clean for the user, that wouldnt even notice this operation. Is there a way to do it? I already have the location of the files in the macro I wrote, so it should make this easier.