Code: Alles auswählen
Ich dacht´ mir:
»createUnoService« ist bekannt,
drum hab ich so genannt!
Was ist damit erreicht?
der Basic-User hat es Leicht!
Code: Alles auswählen
Ich dacht´ mir:
»createUnoService« ist bekannt,
drum hab ich so genannt!
Was ist damit erreicht?
der Basic-User hat es Leicht!
nicht mal reimeln, kann der Deibel!Freischreiber hat geschrieben: ↑Mo 14. Aug 2023, 15:32
Ich will »createUnoService« nicht verteufeln,
es ist für mich nur zum Verzweifeln.
Ja, richtig, da war ein Fehler.
Code: Alles auswählen
Sub DatumzuDateiname
GlobalScope.BasicLibraries.LoadLibrary("Tools")
dim oDoc as Object, msg1 as string, msg2 as string
dim n as integer, sPfad as string, sURL as string, sDateiname as string, sNeuname as string, sDatum as string, sDatumneu as string
' Dim mFileProperties(0) As New com.sun.star.beans.PropertyValue
dim dummy()
msg1 = "Sorry, das Dokument hat noch keine URL!"
msg2 = "Bitte erst einmal speichern"
oDoc = thisComponent
if oDoc.url = "" then
msgbox (msg1 & chr(13) & msg2, 16, "Fehler")
exit sub
end if
sDateiname = FileNameOutOfPath(oDoc.URL)
msgbox sDateiname
sDatum = date()
sDatumneu = Format(sDatum, "YYYY-MM-DD")
msgbox sDatumneu
sNeuname = sDatumneu + " " + sDateiname
msgbox sNeuname
sPfad = replace(convertFromURL(oDoc.url),sDateiname,"")
msgbox sPfad
sURL = convertToURL(sPfad + sNeuname)
msgbox sURL
' mFileProperties(0).Name = "Overwrite"
' mFileProperties(0).Value = True
' oDoc.storeAsUrl(sURL, mFileProperties())
oDoc.storeAsUrl(sURL, dummy())
End Sub
Code: Alles auswählen
convertFromURL
Code: Alles auswählen
convertToURL
Hallo R,F3K Total hat geschrieben: ↑Do 17. Aug 2023, 17:11
Also erstdann wiederCode: Alles auswählen
convertFromURL
Gruß RCode: Alles auswählen
convertToURL
Code: Alles auswählen
uno.fileUrlToSystemPath( url )
##und
uno.systemPathToFileUrl( path )
Code: Alles auswählen
from pathlib import Path
…
uri = Path( … ).as_uri()
Code: Alles auswählen
Sub DatumzuDateiname
GlobalScope.BasicLibraries.LoadLibrary("Tools")
dim oDoc as Object, msg1 as string, msg2 as string
dim n as integer, sPfad as string, sURLneu as string, sURLalt as string, sDateiname as string, sNeuname as string, sDatum as string, sDatumneu as string, sLoeschen as string
dim dummy()
msg1 = "Das Dokument hat noch keinen Dateinamen."
msg2 = "Bitte zuerst einmal speichern."
oDoc = thisComponent
if oDoc.url = "" then
msgbox (msg1 & chr(13) & msg2, 16, "Fehler")
exit sub
end if
sDateiname = FileNameOutOfPath(oDoc.URL)
sURLalt = convertToURL(oDoc.URL)
sDateinameunleer=Replace (sDateiname, " ", "_", 1,-1, False)
sDatum = date()
sDatumneu = Format(sDatum, "YYYY-MM-DD")
sNeuname = sDatumneu + "_" + sDateinameunleer
sPfad = replace(oDoc.url,mid(convertToUrl(oDoc.Title),9),"")
sURLneu = convertToURL(sPfad + sNeuname)
oDoc.storeAsUrl(sURLneu, dummy())
sLoeschen = MsgBox("Ursprüngliche Datei unwiderruflich löschen?" + Chr(13) + sDateiname, 4, "Achtung:")
if sLoeschen = 6 then
kill sURLalt
endif
End Sub