› Excel e gli applicativi Microsoft Office › Scrivere in cella il contenuto di un file txt
-
AutoreArticoli
-
Volevo evitare di porre questa domanda ma non so cosa mettere al posto di :
SHEETS("NOME").RANGE("J11")= #1 ' NON SCRIVE
Sub TROVA_NOME()
Dim NumeroFIle As Integer
INDIRIZZO = ActiveWorkbook.Path
' 1
If Dir(INDIRIZZO & "\Lanciatore\1.LBDP") <> "" Then GoTo NOME_PARTITA_1
NOME_PARTITA_1:
If Dir(INDIRIZZO & "\Lanciatore\A") = "" Then: Exit Sub
Open INDIRIZZO & "\Lanciatore\A" For Input As #1
SHEETS("NOME").RANGE("J11")= #1 ' NON SCRIVE
Close #1 'Chiusura File
Exit Sub
' 2
If Dir(INDIRIZZO & "\Lanciatore\B") <> "" Then GoTo NOME_PARTITA_2
NOME_PARTITA_2:
If Dir(INDIRIZZO & "\Lanciatore\B") = "" Then: Exit Sub
Open INDIRIZZO & "\Lanciatore\2.LBDP" For Input As #1
SHEETS("NOME").RANGE("J11")= #1 ' NON SCRIVE
Close #1 'Chiusura File
Exit Sub
' 3
If Dir(INDIRIZZO & "\Lanciatore\C") <> "" Then GoTo NOME_PARTITA_3
NOME_PARTITA_3:
If Dir(INDIRIZZO & "\Lanciatore\C") = "" Then: Exit Sub
Open INDIRIZZO & "\Lanciatore\3.LBDP" For Input As #1
SHEETS("NOME").RANGE("J11")= #1 ' NON SCRIVE
Close #1 'Chiusura File
Exit Sub
End SubAvevo scritto la domanda bene!Sub TROVA_NOME()
Dim NumeroFIle As Integer
INDIRIZZO = ActiveWorkbook.Path
' 1
If Dir(INDIRIZZO & "\Lanciatore\1.LBDP") <> "" Then GoTo NOME_PARTITA_1
NOME_PARTITA_1:
If Dir(INDIRIZZO & "\Lanciatore\A") = "" Then: Exit Sub
Open INDIRIZZO & "\Lanciatore\A" For Input As #1
SHEETS("NOME").RANGE("J11")= #1 ' NON SCRIVE
Close #1 'Chiusura File
Exit Sub
' 2
If Dir(INDIRIZZO & "\Lanciatore\B") <> "" Then GoTo NOME_PARTITA_2
NOME_PARTITA_2:
If Dir(INDIRIZZO & "\Lanciatore\B") = "" Then: Exit Sub
Open INDIRIZZO & "\Lanciatore\2.LBDP" For Input As #1
SHEETS("NOME").RANGE("J11")= #1 ' NON SCRIVE
Close #1 'Chiusura File
Exit Sub
' 3
If Dir(INDIRIZZO & "\Lanciatore\C") <> "" Then GoTo NOME_PARTITA_3
NOME_PARTITA_3:
If Dir(INDIRIZZO & "\Lanciatore\C") = "" Then: Exit Sub
Open INDIRIZZO & "\Lanciatore\3.LBDP" For Input As #1
SHEETS("NOME").RANGE("J11")= #1 ' NON SCRIVE
Close #1 'Chiusura File
Exit Sub
End SubLa funzione incolla non funziona in questo sito!!Ho allegato il file...Allegati:
You must be logged in to view attached files.oltre all'errore ho confuso nelle celle ci devono andare A B C.Sub TROVA_NOME() Dim NumeroFIle As Integer INDIRIZZO = ActiveWorkbook.Path ' 1 If Dir(INDIRIZZO & "\Lanciatore\1.LBDP") <> "" Then GoTo NOME_PARTITA_1 NOME_PARTITA_1: If Dir(INDIRIZZO & "\Lanciatore\A") = "" Then: Exit Sub Open INDIRIZZO & "\Lanciatore\A" For Input As #1 ' scrivere in Sheets("NOME").Range("J11") contenuto file A Close #1 'Chiusura File Exit Sub ' 2 If Dir(INDIRIZZO & "\Lanciatore\B") <> "" Then GoTo NOME_PARTITA_2 NOME_PARTITA_2: If Dir(INDIRIZZO & "\Lanciatore\B") = "" Then: Exit Sub Open INDIRIZZO & "\Lanciatore\2.LBDP" For Input As #1 ' scrivere in Sheets("NOME").Range("J11") contenuto file B Close #1 'Chiusura File Exit Sub ' 3 If Dir(INDIRIZZO & "\Lanciatore\C") <> "" Then GoTo NOME_PARTITA_3 NOME_PARTITA_3: If Dir(INDIRIZZO & "\Lanciatore\C") = "" Then: Exit Sub Open INDIRIZZO & "\Lanciatore\3.LBDP" For Input As #1 ' scrivere in Sheets("NOME").Range("J11") contenuto file C Close #1 'Chiusura File Exit Sub End SubSub TROVA_NOME() Dim NumeroFIle As Integer INDIRIZZO = ActiveWorkbook.Path ' 1 If Dir(INDIRIZZO & "\Lanciatore\1.LBDP") <> "" Then GoTo NOME_PARTITA_1 NOME_PARTITA_1: If Dir(INDIRIZZO & "\Lanciatore\A") = "" Then: Exit Sub Open INDIRIZZO & "\Lanciatore\A" For Input As #1 ' scrivere in Sheets("NOME").Range("J11") contenuto file A Close #1 'Chiusura File Exit Sub ' 2 If Dir(INDIRIZZO & "\Lanciatore\2.LBDP") <> "" Then GoTo NOME_PARTITA_2 NOME_PARTITA_2: If Dir(INDIRIZZO & "\Lanciatore\B") = "" Then: Exit Sub Open INDIRIZZO & "\Lanciatore\B" For Input As #1 ' scrivere in Sheets("NOME").Range("J11") contenuto file B Close #1 'Chiusura File Exit Sub ' 3 If Dir(INDIRIZZO & "\Lanciatore\3.LBDP") <> "" Then GoTo NOME_PARTITA_3 NOME_PARTITA_3: If Dir(INDIRIZZO & "\Lanciatore\C") = "" Then: Exit Sub Open INDIRIZZO & "\Lanciatore\C" For Input As #1 ' scrivere in Sheets("NOME").Range("J11") contenuto file C Close #1 'Chiusura File Exit Sub End SubOscar sai rispondere!Devo scrivere il contenuto di A B C nella cella J11 del foglio NOME.Nei spazi vuoti mi servirebbe il codice per prelevare il testo del file ( A B C ) e incollarlo nella cella j11
Sub TROVA_NOME() Dim NumeroFIle As Integer INDIRIZZO = ActiveWorkbook.Path ' 1 If Dir(INDIRIZZO & "\Lanciatore\1.LBDP") <> "" Then GoTo NOME_PARTITA_1 Else GoTo 2 NOME_PARTITA_1: If Dir(INDIRIZZO & "\Lanciatore\A") = "" Then: Exit Sub Open INDIRIZZO & "\Lanciatore\A" For Input As #1 Close #1 'Chiusura File Exit Sub ' 2 2: If Dir(INDIRIZZO & "\Lanciatore\B") <> "" Then GoTo NOME_PARTITA_2 Else GoTo 3 NOME_PARTITA_2: If Dir(INDIRIZZO & "\Lanciatore\B") = "" Then: Exit Sub Open INDIRIZZO & "\Lanciatore\2.LBDP" For Input As #1 Close #1 'Chiusura File Exit Sub ' 3 3: If Dir(INDIRIZZO & "\Lanciatore\C") <> "" Then GoTo NOME_PARTITA_3 Else GoTo ESCI NOME_PARTITA_3: If Dir(INDIRIZZO & "\Lanciatore\C") = "" Then: Exit Sub Open INDIRIZZO & "\Lanciatore\3.LBDP" For Input As #1 Close #1 'Chiusura File ESCI: Exit SubCon questo forum è davvero impossibile inserire il codice non lo copia corretto è da rivedere.DOVREBBE ESSERE : PRINT#1, SHEETS("NOME").RANGE("J11")LA PROVO SUBITO...!Non funziona!Possibile che nessuno rispondeSub TROVA_NOME() Dim NumeroFIle As Integer INDIRIZZO = ActiveWorkbook.Path ' 1 If Dir(INDIRIZZO & "\Lanciatore\1.LBDP") <> "" Then GoTo NOME_PARTITA_1 Else GoTo 2 NOME_PARTITA_1: If Dir(INDIRIZZO & "\Lanciatore\A") = "" Then: Exit Sub Open INDIRIZZO & "\Lanciatore\A" For Input As #1 Print #1, Sheets("NOME").Range("J11") Close #1 'Chiusura File Exit Sub ' 2 2: If Dir(INDIRIZZO & "\Lanciatore\2.LBDP") <> "" Then GoTo NOME_PARTITA_2 Else GoTo 3 NOME_PARTITA_2: If Dir(INDIRIZZO & "\Lanciatore\B") = "" Then: Exit Sub Open INDIRIZZO & "\Lanciatore\B" For Input As #1 Print #1, Sheets("NOME").Range("J11") Close #1 'Chiusura File Exit Sub ' 3 3: If Dir(INDIRIZZO & "\Lanciatore\3.LBDP") <> "" Then GoTo NOME_PARTITA_3 Else GoTo ESCI NOME_PARTITA_3: If Dir(INDIRIZZO & "\Lanciatore\C") = "" Then: Exit Sub Open INDIRIZZO & "\Lanciatore\C" For Input As #1 Print #1, Sheets("NOME").Range("J11") Close #1 'Chiusura File ESCI: Exit Sub End SubPossibile che nessuno rispondeNon rispondiamo a chiamata, mettiamo a disposizione degli utenti del forum il nostro tempo libero per cercare di risolvere i vari quesiti,dopo di che , ci sono modi e modi di porsi.Qual è il punto di avere gusti diversi, se non mostrare che i cervelli lavorano diversamente, che pensiamo diversamente? ( Alan Turing)
Sempre il mare, uomo libero, amerai!
( Charles Baudelaire )Di le stesse cose ha Oscar che ha risposto (Cos’è sto romanzo) vedendo che trovavo difficoltà nel porre la domanda!!... dopo di che , ci sono modi e modi di porsi.è davvero impossibile riprovo.Di le stesse cose ha Oscar che ha risposto (cos'è sto romanzo) vedendo la difficoltà nel postare la domanda! dopo di che, ci sono modi e modi di porsi.Sub ImportaFileTesto() FileTesto = ActiveWorkbook.Path & "\FileTesto.txt" Open FileTesto For Input As #1 nRiga = 0 leggiAncora: nRiga = nRiga + 1 If Not EOF(1) Then Line Input #1, Riga$ Cells(Numriga, 1) = Riga$ GoTo leggiAncora End If Close #1 End SubHo risolto adattando questo codice. -
AutoreArticoli
