Bustrek
Guest
salve a tutti
ho una domanda per ilogic, premessa non sono in grado di programmare in ilogic e nemmo in vb, ma rubando in qua e la un paio di stringhe ho messo in piedi un codice per aggiornare di massa le proprietà dei file cad leggendole da excel, il tutto partendo da un file di assieme. l’unica cosa che non funziona e che mi carica sempre la riga dati del codice dell’assieme di partenza e non dei file che mi apre.
se qualcuno ha qualche info il lo ringrazio in anticipo.
vi allego il codice:
dim odoc as document = thisapplication.activedocument
dim adoc as documentsenumerator = odoc.allreferenceddocuments
dim idoc as document
dim xdoc as document
for each idoc in adoc
xdoc = thisapplication.documents.open(idoc.fullfilename, true) 'false means it will open invisible
startrule:
'legge il file excel
'goexcel.open ("c:\users\michele\onedrive\documenti\codifica salvamac.xlsx","sheet1")
goexcel.open("c:\ut\prg\salvamac\p100\bom p100003.xlsx", "bom")
'indice riga da 2 a 10000
for rowpn = 2 to 10000
'trova la prima cella vuota nella colonna a
if (goexcel.cellvalue("e" & rowpn) = thisdoc.filename) then
'crea una variabile per il valore della cella inferiore di una riga
'la riga di cella vuota
lastpn = goexcel.cellvalue("e" & rowpn)
lastdesc = goexcel.cellvalue("f" & rowpn)
dse = goexcel.cellvalue("ae" & rowpn)
data = goexcel.cellvalue("g" & rowpn)
dev = goexcel.cellvalue("h" & rowpn)
snq = goexcel.cellvalue("i" & rowpn)
rah = goexcel.cellvalue("j" & rowpn)
mat = goexcel.cellvalue("p" & rowpn)
fom = goexcel.cellvalue("q" & rowpn)
trf = goexcel.cellvalue("r" & rowpn)
tri = goexcel.cellvalue("ag" & rowpn)
gdp = goexcel.cellvalue("s" & rowpn)
cat = goexcel.cellvalue("m" & rowpn)
tar = goexcel.cellvalue("k" & rowpn)
lav = goexcel.cellvalue("n" & rowpn)
tap = goexcel.cellvalue("o" & rowpn)
fon = goexcel.cellvalue("l" & rowpn)
r1d = goexcel.cellvalue("t" & rowpn)
r1t = goexcel.cellvalue("u" & rowpn)
r1a = goexcel.cellvalue("v" & rowpn)
r2d = goexcel.cellvalue("w" & rowpn)
r2t = goexcel.cellvalue("x" & rowpn)
r2a = goexcel.cellvalue("y" & rowpn)
r3d = goexcel.cellvalue("z" & rowpn)
r3t = goexcel.cellvalue("aa" & rowpn)
r3a = goexcel.cellvalue("ab" & rowpn)
nte = goexcel.cellvalue("ac" & rowpn)
ssc = goexcel.cellvalue("ad" & rowpn)
exit for
end if
next
'controlla se il numero codice è uguale al nome del file o è vuoto
if iproperties.value("project", "part number") = thisdoc.filename(false) _
or iproperties.value("project", "part number") = "" then
'imposta iproperty sul valore letto da excel
iproperties.value("project", "part number") = lastpn
iproperties.value("project", "description") = lastdesc
iproperties.value("custom", "description") = dse
iproperties.value("custom", "data") = data
iproperties.value("custom", "derivato da") = dev
iproperties.value("custom", "smussi non quotati") = snq
iproperties.value("custom", "rugosita' ra") = rah
iproperties.value("custom", "materiale") = mat
iproperties.value("custom", "forma materiale") = fom
iproperties.value("custom", "trattamento finale") = trf
iproperties.value("custom", "trattamento intermedio") = tri
iproperties.value("custom", "grado precisione") = gdp
iproperties.value("custom", "categoria") = cat
iproperties.value("custom", "tipo articolo") = tar
iproperties.value("custom", "lavorazione") = lav
iproperties.value("custom", "tipo appov. primario") = tap
iproperties.value("custom", "fornitore") = fon
iproperties.value("custom", "r01_data") = r1d
iproperties.value("custom", "r01_testo") = r1t
iproperties.value("custom", "r01_autore") = r1a
iproperties.value("custom", "r02_data") = r2d
iproperties.value("custom", "r02_testo") = r2t
iproperties.value("custom", "r02_autore") = r2a
iproperties.value("custom", "r03_data") = r3d
iproperties.value("custom", "r03_testo") = r3t
iproperties.value("custom", "r03_autore") = r3a
iproperties.value("custom", "note") = nte
iproperties.value("custom", "sostituisce il") = ssc
else
end if
'mostra e chiede di confermare i risultati
question = messagebox.show("codice: " & lastpn & vblf _
&"descrizione: " & lastdesc & vblf _
& "sono corrette?", "proprietà da excel", messageboxbuttons.yesno )
'se la risposta è no
if question = vbno then
'cancella queste iproperties testato ok
iproperties.value("project", "part number") = ""
iproperties.value("project", "description") = ""
iproperties.value("custom", "description") = ""
iproperties.value("custom", "data") = ""
iproperties.value("custom", "derivato da") = ""
iproperties.value("custom", "smussi non quotati") = ""
iproperties.value("custom", "rugosita' ra") = ""
iproperties.value("custom", "materiale") = ""
iproperties.value("custom", "forma materiale") = ""
iproperties.value("custom", "data") = ""
iproperties.value("custom", "trattamento finale") = ""
iproperties.value("custom", "trattamento intermedio") = ""
iproperties.value("custom", "grado precisione") = ""
iproperties.value("custom", "categoria") = ""
iproperties.value("custom", "tipo articolo") = ""
iproperties.value("custom", "lavorazione") = ""
iproperties.value("custom", "tipo appov. primario") = ""
iproperties.value("custom", "fornitore") = ""
iproperties.value("custom", "r01_data") = ""
iproperties.value("custom", "r01_testo") = ""
iproperties.value("custom", "r01_autore") = ""
iproperties.value("custom", "r02_data") = ""
iproperties.value("custom", "r02_testo") = ""
iproperties.value("custom", "r02_autore") = ""
iproperties.value("custom", "r03_data") = ""
iproperties.value("custom", "r03_testo") = ""
iproperties.value("custom", "r03_autore") = ""
iproperties.value("custom", "note") = ""
iproperties.value("custom", "sostituisce il") = ""
'esegui di nuovo la regola
goto startrule
'se la risposta è sì regola di uscita
else end if
'ilogicvb.runexternalrule("proprietà")
'xdoc.save
xdoc.close(true)
next
ho una domanda per ilogic, premessa non sono in grado di programmare in ilogic e nemmo in vb, ma rubando in qua e la un paio di stringhe ho messo in piedi un codice per aggiornare di massa le proprietà dei file cad leggendole da excel, il tutto partendo da un file di assieme. l’unica cosa che non funziona e che mi carica sempre la riga dati del codice dell’assieme di partenza e non dei file che mi apre.
se qualcuno ha qualche info il lo ringrazio in anticipo.
vi allego il codice:
dim odoc as document = thisapplication.activedocument
dim adoc as documentsenumerator = odoc.allreferenceddocuments
dim idoc as document
dim xdoc as document
for each idoc in adoc
xdoc = thisapplication.documents.open(idoc.fullfilename, true) 'false means it will open invisible
startrule:
'legge il file excel
'goexcel.open ("c:\users\michele\onedrive\documenti\codifica salvamac.xlsx","sheet1")
goexcel.open("c:\ut\prg\salvamac\p100\bom p100003.xlsx", "bom")
'indice riga da 2 a 10000
for rowpn = 2 to 10000
'trova la prima cella vuota nella colonna a
if (goexcel.cellvalue("e" & rowpn) = thisdoc.filename) then
'crea una variabile per il valore della cella inferiore di una riga
'la riga di cella vuota
lastpn = goexcel.cellvalue("e" & rowpn)
lastdesc = goexcel.cellvalue("f" & rowpn)
dse = goexcel.cellvalue("ae" & rowpn)
data = goexcel.cellvalue("g" & rowpn)
dev = goexcel.cellvalue("h" & rowpn)
snq = goexcel.cellvalue("i" & rowpn)
rah = goexcel.cellvalue("j" & rowpn)
mat = goexcel.cellvalue("p" & rowpn)
fom = goexcel.cellvalue("q" & rowpn)
trf = goexcel.cellvalue("r" & rowpn)
tri = goexcel.cellvalue("ag" & rowpn)
gdp = goexcel.cellvalue("s" & rowpn)
cat = goexcel.cellvalue("m" & rowpn)
tar = goexcel.cellvalue("k" & rowpn)
lav = goexcel.cellvalue("n" & rowpn)
tap = goexcel.cellvalue("o" & rowpn)
fon = goexcel.cellvalue("l" & rowpn)
r1d = goexcel.cellvalue("t" & rowpn)
r1t = goexcel.cellvalue("u" & rowpn)
r1a = goexcel.cellvalue("v" & rowpn)
r2d = goexcel.cellvalue("w" & rowpn)
r2t = goexcel.cellvalue("x" & rowpn)
r2a = goexcel.cellvalue("y" & rowpn)
r3d = goexcel.cellvalue("z" & rowpn)
r3t = goexcel.cellvalue("aa" & rowpn)
r3a = goexcel.cellvalue("ab" & rowpn)
nte = goexcel.cellvalue("ac" & rowpn)
ssc = goexcel.cellvalue("ad" & rowpn)
exit for
end if
next
'controlla se il numero codice è uguale al nome del file o è vuoto
if iproperties.value("project", "part number") = thisdoc.filename(false) _
or iproperties.value("project", "part number") = "" then
'imposta iproperty sul valore letto da excel
iproperties.value("project", "part number") = lastpn
iproperties.value("project", "description") = lastdesc
iproperties.value("custom", "description") = dse
iproperties.value("custom", "data") = data
iproperties.value("custom", "derivato da") = dev
iproperties.value("custom", "smussi non quotati") = snq
iproperties.value("custom", "rugosita' ra") = rah
iproperties.value("custom", "materiale") = mat
iproperties.value("custom", "forma materiale") = fom
iproperties.value("custom", "trattamento finale") = trf
iproperties.value("custom", "trattamento intermedio") = tri
iproperties.value("custom", "grado precisione") = gdp
iproperties.value("custom", "categoria") = cat
iproperties.value("custom", "tipo articolo") = tar
iproperties.value("custom", "lavorazione") = lav
iproperties.value("custom", "tipo appov. primario") = tap
iproperties.value("custom", "fornitore") = fon
iproperties.value("custom", "r01_data") = r1d
iproperties.value("custom", "r01_testo") = r1t
iproperties.value("custom", "r01_autore") = r1a
iproperties.value("custom", "r02_data") = r2d
iproperties.value("custom", "r02_testo") = r2t
iproperties.value("custom", "r02_autore") = r2a
iproperties.value("custom", "r03_data") = r3d
iproperties.value("custom", "r03_testo") = r3t
iproperties.value("custom", "r03_autore") = r3a
iproperties.value("custom", "note") = nte
iproperties.value("custom", "sostituisce il") = ssc
else
end if
'mostra e chiede di confermare i risultati
question = messagebox.show("codice: " & lastpn & vblf _
&"descrizione: " & lastdesc & vblf _
& "sono corrette?", "proprietà da excel", messageboxbuttons.yesno )
'se la risposta è no
if question = vbno then
'cancella queste iproperties testato ok
iproperties.value("project", "part number") = ""
iproperties.value("project", "description") = ""
iproperties.value("custom", "description") = ""
iproperties.value("custom", "data") = ""
iproperties.value("custom", "derivato da") = ""
iproperties.value("custom", "smussi non quotati") = ""
iproperties.value("custom", "rugosita' ra") = ""
iproperties.value("custom", "materiale") = ""
iproperties.value("custom", "forma materiale") = ""
iproperties.value("custom", "data") = ""
iproperties.value("custom", "trattamento finale") = ""
iproperties.value("custom", "trattamento intermedio") = ""
iproperties.value("custom", "grado precisione") = ""
iproperties.value("custom", "categoria") = ""
iproperties.value("custom", "tipo articolo") = ""
iproperties.value("custom", "lavorazione") = ""
iproperties.value("custom", "tipo appov. primario") = ""
iproperties.value("custom", "fornitore") = ""
iproperties.value("custom", "r01_data") = ""
iproperties.value("custom", "r01_testo") = ""
iproperties.value("custom", "r01_autore") = ""
iproperties.value("custom", "r02_data") = ""
iproperties.value("custom", "r02_testo") = ""
iproperties.value("custom", "r02_autore") = ""
iproperties.value("custom", "r03_data") = ""
iproperties.value("custom", "r03_testo") = ""
iproperties.value("custom", "r03_autore") = ""
iproperties.value("custom", "note") = ""
iproperties.value("custom", "sostituisce il") = ""
'esegui di nuovo la regola
goto startrule
'se la risposta è sì regola di uscita
else end if
'ilogicvb.runexternalrule("proprietà")
'xdoc.save
xdoc.close(true)
next