Seite 1 von 1

Re: Makro zum Text kopieren und Variable hochzählen

Verfasst: Do, 13.03.2014 21:20
von Stephan
Ich verstehe das genaue Ziel nicht, also wo die Texte hin sollen.
Folgendes Makro schreibt sie in Spalte A einer Calc-Tabelle:

Code: Alles auswählen

Sub Main
	txt = ""
	For i = 1 to 999
		tmp = String(4-LEN(i),"0") & i
		txt = txt & "<a href=""img/Fotos/Bild"
		txt = txt & tmp
		txt = txt & ".jpg"" data-lightbox=""Obst""><img src=""img/Fotos/Bild"
		txt = txt & tmp
		txt = txt & "_thumbnail.jpg""></a>"
		ThisComponent.Sheets(0).getCellRangeByName("A"&i).String = txt
		txt = ""
	Next i
End Sub
Gruß
Stephan

Re: Makro zum Text kopieren und Variable hochzählen

Verfasst: Fr, 14.03.2014 11:27
von Karolus
Hallo

Ich schieb hier mal zum Vergleichen nach wie das in Python ginge:

Code: Alles auswählen

def nummerierung():

    template =( '<a href="img/Fotos/Bild{0:04d}.jpg" '
    'data-lightbox="Obst"><img src="img/Fotos/Bild'
    '{0:04d}_thumbnail.jpg"></a>'.format )

    doc = XSCRIPTCONTEXT.getDocument()
    sheet = doc.Sheets.getByIndex(0)
    out = [(template(x),) for x in range(1,1256)]
    crange = sheet.getCellRangeByPosition(0,0,0,len(out)-1)
    crange.DataArray =tuple( out ) 
Karolus