Ouverture de fichier
Bonjour,
je dois ouvrir un fichier texte en vba et colorier les cellules selon le contenu de lignes.
j'ai fait ce programme ms ca ne marche pas
sub ouverture
dim feuille as object, l as integer, niveau as string, sline as string
maFeuille = thiscomponent.sheets.getbyname("Sheet1")
niveau = "C:\Users\Pc\Desktop\niv1.txt"
tania = freefile
open niveau for input as tania
line input #tania, sline
col=sline
line input #tania, sline
lig=sline
line input #tania, sline
posx=sline
line input #tania, sline
posy=sline
call FRectangle(mafeuille, 0, 0, col-1, lig-1)
Do While not eof(tania)
for l=4 to col*lig
dim u as integer, v as integer
for u= 0 to col
for v=0 to lig
line input #tania, sline
I = left (sline,l)
if I = "v" then
maFeuille.getcellbyposition(u,v).cellbackcolor=rgb(160, 160, 160)
end if
if I = "x" then
maFeuille.getcellbyposition(u,v).cellbackcolor=rgb(0, 0, 0)
end if
next v
next u
next l
Loop
Close #tania
maFeuille.getcellbyposition(u,v).cellbackcolor=rgb(0, 0, 204)
end sub