Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > it.comp.lang.visual-basic > #20009
| X-Received | by 2002:ae9:f302:0:b0:6fc:aae3:664a with SMTP id p2-20020ae9f302000000b006fcaae3664amr5486433qkg.459.1669993387091; Fri, 02 Dec 2022 07:03:07 -0800 (PST) |
|---|---|
| X-Received | by 2002:a37:783:0:b0:6fc:add0:6639 with SMTP id 125-20020a370783000000b006fcadd06639mr4147075qkh.310.1669993386816; Fri, 02 Dec 2022 07:03:06 -0800 (PST) |
| Path | csiph.com!1.us.feeder.erje.net!feeder.erje.net!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail |
| Newsgroups | it.comp.lang.visual-basic |
| Date | Fri, 2 Dec 2022 07:03:06 -0800 (PST) |
| In-Reply-To | <d8b29811-7c2e-48ce-9f1a-a51b2b66ad19n@googlegroups.com> |
| Injection-Info | google-groups.googlegroups.com; posting-host=147.161.245.109; posting-account=yvxj_woAAABxrxq8XihQzP-tWUWpycQc |
| NNTP-Posting-Host | 147.161.245.109 |
| References | <d8b29811-7c2e-48ce-9f1a-a51b2b66ad19n@googlegroups.com> |
| User-Agent | G2/1.0 |
| MIME-Version | 1.0 |
| Message-ID | <c5eedbb3-ab76-4c4a-8b58-4b1915ed6691n@googlegroups.com> (permalink) |
| Subject | Re: leggere file txt e popolare celle Excel |
| From | Marco75 <marcoporzi75@gmail.com> |
| Injection-Date | Fri, 02 Dec 2022 15:03:07 +0000 |
| Content-Type | text/plain; charset="UTF-8" |
| Content-Transfer-Encoding | quoted-printable |
| X-Received-Bytes | 3464 |
| Xref | csiph.com it.comp.lang.visual-basic:20009 |
Show key headers only | View raw
Il giorno venerdì 2 dicembre 2022 alle 15:43:33 UTC+1 Marco75 ha scritto:
> Ciao,
> ho un file txt con 3 informazioni poste su 3 righe.
> vorrei leggere questo file e mettere:
> - contenuto riga 1 in cella C2
> - contenuto riga 2 in cella D2
> - contenuto riga 3 in cella E2
>
> ora ho provato così ma non è corretto...
>
> Dim FilePath As String
> Dim strFirstLine As String
> Dim strSecondLine As String
>
> Dim aFile As String
> aFile = "C:\Interventi macina CQ\Ultima ricetta.txt"
> If Len(Dir$(aFile)) > 0 Then
>
> FilePath = "C:\Interventi macina CQ\Ultima ricetta.txt"
>
> Open FilePath For Input As #1
> Line Input #1, strFirstLine
> MsgBox (strFirstLine)
> Close #1
>
> Open FilePath For Input As #2
> Line Input #2, strFirstLine
> MsgBox (strFirstLine)
> Close #2
>
> End If
>
> in attesa di cortese risposta continuerò a provare
> grazie
> Marco
ho rivisto un po' il codice:
Dim my_file As Integer
Dim text_line As String
Dim file_name As String
Dim i As Integer
Dim aFile As String
aFile = "C:\Interventi macina CQ\Ultima ricetta.txt"
If Len(Dir$(aFile)) > 0 Then
file_name = "C:\Interventi macina CQ\Ultima ricetta.txt"
my_file = FreeFile()
Open file_name For Input As my_file
i = 1
While Not EOF(my_file)
Line Input #my_file, text_line
Cells(i, "H").Value = text_line
i = i + 1
Wend
ActiveSheet.Range("C2").Value = ActiveSheet.Range("H1").Value
ActiveSheet.Range("D2").Value = ActiveSheet.Range("H2").Value
ActiveSheet.Range("E2").Value = ActiveSheet.Range("H3").Value
ActiveSheet.Range("H1:H3").Select
ActiveSheet.Range("H1:H3").ClearContents
ActiveSheet.Range("C2").Select
End If
riesco a leggere il file e mi mette le 3 righe del file nella colonna H (da H1 a H3)
io però le voglio in riga quindi vado a popolarmi le celle poi cancello i dati della colonna H
non è bellissimo ma funziona, resto in attesa di suggerimenti per mettere i 3 dati in C2, D2 ed E2
grazie
Marco
Back to it.comp.lang.visual-basic | Previous | Next — Previous in thread | Next in thread | Find similar
leggere file txt e popolare celle Excel Marco75 <marcoporzi75@gmail.com> - 2022-12-02 06:43 -0800 Re: leggere file txt e popolare celle Excel Marco75 <marcoporzi75@gmail.com> - 2022-12-02 07:03 -0800 Re: leggere file txt e popolare celle Excel "Sauro" <vicchi@crsscala.it> - 2022-12-15 17:00 +0100
csiph-web