{"id":4990,"date":"2023-07-05T12:39:33","date_gmt":"2023-07-05T12:39:33","guid":{"rendered":"https:\/\/statorials.org\/it\/apri-il-file-vba-csv\/"},"modified":"2023-07-05T12:39:33","modified_gmt":"2023-07-05T12:39:33","slug":"apri-il-file-vba-csv","status":"publish","type":"post","link":"https:\/\/statorials.org\/it\/apri-il-file-vba-csv\/","title":{"rendered":"Come aprire un file csv utilizzando vba (con esempio)"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">\u00c8 possibile utilizzare il metodo <b>Workbooks.Open<\/b> in VBA per aprire un file CSV da un percorso file specifico.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Ecco un modo comune per utilizzare questo metodo nella pratica:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #0000ff;\">SubOpenCSV<\/span> ()\nWorkbooks.Open \"C:\\Users\\bob\\Documents\\team_info.csv\"\n<span style=\"color: #0000ff;\">End Sub\n<\/span><\/strong><\/span><\/pre>\n<p> <span style=\"color: #000000;\">Questa particolare macro apre il file CSV chiamato <strong>team_info.csv<\/strong> situato in un percorso di file specifico sul mio computer.<\/span><\/p>\n<p> <span style=\"color: #000000;\">L&#8217;esempio seguente mostra come utilizzare nella pratica questa sintassi per aprire un file CSV.<\/span><\/p>\n<h2> <span style=\"color: #000000;\"><strong>Esempio: come aprire un file CSV utilizzando VBA<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">Supponiamo di avere un file CSV chiamato <strong>team_info.csv<\/strong> situato nel seguente percorso di file sul mio computer:<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>C:\\Utenti\\bob\\Documenti\\team_info.csv<\/strong><\/span><\/p>\n<p> <span style=\"color: #000000;\">Diciamo che voglio aprire questo file CSV in Excel utilizzando VBA.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Per fare ci\u00f2 possiamo creare la seguente macro:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #0000ff;\">SubOpenCSV<\/span> ()\nWorkbooks.Open \"C:\\Users\\bob\\Documents\\team_info.csv\"\n<span style=\"color: #0000ff;\">End Sub<\/span><\/strong><\/span><\/pre>\n<p> <span style=\"color: #000000;\">Quando eseguiamo questa macro, il file CSV verr\u00e0 aperto automaticamente:<\/span> <\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-38895 aligncenter\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/opencsv1.png\" alt=\"\" width=\"491\" height=\"389\" srcset=\"\" sizes=\"\"><\/p>\n<p> <span style=\"color: #000000;\">Il file contiene informazioni su varie squadre di basket.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Tieni presente che se utilizzassimo il percorso errato per il file CSV, riceveremmo un messaggio di errore da VBA.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Ad esempio, supponiamo di provare ad aprire un file chiamato <strong>team_info2.csv<\/strong> , che non esiste:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #0000ff;\">SubOpenCSV<\/span> ()\nWorkbooks.Open \"C:\\Users\\bob\\Documents\\team_info2.csv\"\n<span style=\"color: #0000ff;\">End Sub<\/span><\/strong><\/span><\/pre>\n<p> <span style=\"color: #000000;\">Quando eseguo questa macro, ricevo il seguente messaggio di errore da VBA:<\/span> <\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-38896 aligncenter\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/ouvertcsv2.png\" alt=\"\" width=\"423\" height=\"257\" srcset=\"\" sizes=\"\"><\/p>\n<p> <span style=\"color: #000000;\">Il messaggio di errore ci informa che non \u00e8 stato possibile trovare il file CSV.<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>Nota<\/strong> : puoi trovare la documentazione completa per il metodo <b>Workbooks.Open<\/b> <a href=\"https:\/\/learn.microsoft.com\/en-us\/office\/vba\/api\/excel.workbooks.open\" target=\"_blank\" rel=\"noopener\">qui<\/a> .<\/span><\/p>\n<h2> <span style=\"color: #000000;\"><strong>Risorse addizionali<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">I seguenti tutorial spiegano come eseguire altre attivit\u00e0 comuni in VBA:<\/span><\/p>\n<p> <span style=\"color: #000000;\"><a href=\"https:\/\/statorials.org\/it\/aprire-il-file-di-testo-vba\/\" target=\"_blank\" rel=\"noopener\">Come aprire un file di testo utilizzando VBA<\/a><br \/> <a href=\"https:\/\/statorials.org\/it\/apri-vba-pdf\/\" target=\"_blank\" rel=\"noopener\">Come aprire un PDF con VBA<\/a><br \/> <a href=\"https:\/\/statorials.org\/it\/vba-crea-cartella\/\" target=\"_blank\" rel=\"noopener\">Come creare cartelle utilizzando VBA<\/a><br \/><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u00c8 possibile utilizzare il metodo Workbooks.Open in VBA per aprire un file CSV da un percorso file specifico. Ecco un modo comune per utilizzare questo metodo nella pratica: SubOpenCSV () Workbooks.Open &#8220;C:\\Users\\bob\\Documents\\team_info.csv&#8221; End Sub Questa particolare macro apre il file CSV chiamato team_info.csv situato in un percorso di file specifico sul mio computer. L&#8217;esempio seguente [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Come aprire un file CSV utilizzando VBA (con esempio) - Statorials<\/title>\n<meta name=\"description\" content=\"Questo tutorial spiega come aprire un file CSV utilizzando VBA, con un esempio completo.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/statorials.org\/it\/apri-il-file-vba-csv\/\" \/>\n<meta property=\"og:locale\" content=\"it_IT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Come aprire un file CSV utilizzando VBA (con esempio) - Statorials\" \/>\n<meta property=\"og:description\" content=\"Questo tutorial spiega come aprire un file CSV utilizzando VBA, con un esempio completo.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/it\/apri-il-file-vba-csv\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-05T12:39:33+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/opencsv1.png\" \/>\n<meta name=\"author\" content=\"Benjamin anderson\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Benjamin anderson\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minuto\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/it\/apri-il-file-vba-csv\/\",\"url\":\"https:\/\/statorials.org\/it\/apri-il-file-vba-csv\/\",\"name\":\"Come aprire un file CSV utilizzando VBA (con esempio) - Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/it\/#website\"},\"datePublished\":\"2023-07-05T12:39:33+00:00\",\"dateModified\":\"2023-07-05T12:39:33+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae\"},\"description\":\"Questo tutorial spiega come aprire un file CSV utilizzando VBA, con un esempio completo.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/it\/apri-il-file-vba-csv\/#breadcrumb\"},\"inLanguage\":\"it-IT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/it\/apri-il-file-vba-csv\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/it\/apri-il-file-vba-csv\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Casa\",\"item\":\"https:\/\/statorials.org\/it\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Come aprire un file csv utilizzando vba (con esempio)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/statorials.org\/it\/#website\",\"url\":\"https:\/\/statorials.org\/it\/\",\"name\":\"Statorials\",\"description\":\"La tua guida all&#039;alfabetizzazione statistica!\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/statorials.org\/it\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"it-IT\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae\",\"name\":\"Benjamin anderson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"it-IT\",\"@id\":\"https:\/\/statorials.org\/it\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/statorials.org\/it\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"contentUrl\":\"https:\/\/statorials.org\/it\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"caption\":\"Benjamin anderson\"},\"description\":\"Ciao, sono Benjamin, un professore di statistica in pensione diventato insegnante dedicato di Statorials. Con una vasta esperienza e competenza nel campo della statistica, sono ansioso di condividere le mie conoscenze per potenziare gli studenti attraverso Statorials. Scopri di pi\u00f9\",\"sameAs\":[\"https:\/\/statorials.org\/it\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Come aprire un file CSV utilizzando VBA (con esempio) - Statorials","description":"Questo tutorial spiega come aprire un file CSV utilizzando VBA, con un esempio completo.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/statorials.org\/it\/apri-il-file-vba-csv\/","og_locale":"it_IT","og_type":"article","og_title":"Come aprire un file CSV utilizzando VBA (con esempio) - Statorials","og_description":"Questo tutorial spiega come aprire un file CSV utilizzando VBA, con un esempio completo.","og_url":"https:\/\/statorials.org\/it\/apri-il-file-vba-csv\/","og_site_name":"Statorials","article_published_time":"2023-07-05T12:39:33+00:00","og_image":[{"url":"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/opencsv1.png"}],"author":"Benjamin anderson","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Benjamin anderson","Est. reading time":"1 minuto"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/it\/apri-il-file-vba-csv\/","url":"https:\/\/statorials.org\/it\/apri-il-file-vba-csv\/","name":"Come aprire un file CSV utilizzando VBA (con esempio) - Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/it\/#website"},"datePublished":"2023-07-05T12:39:33+00:00","dateModified":"2023-07-05T12:39:33+00:00","author":{"@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae"},"description":"Questo tutorial spiega come aprire un file CSV utilizzando VBA, con un esempio completo.","breadcrumb":{"@id":"https:\/\/statorials.org\/it\/apri-il-file-vba-csv\/#breadcrumb"},"inLanguage":"it-IT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/it\/apri-il-file-vba-csv\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/it\/apri-il-file-vba-csv\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Casa","item":"https:\/\/statorials.org\/it\/"},{"@type":"ListItem","position":2,"name":"Come aprire un file csv utilizzando vba (con esempio)"}]},{"@type":"WebSite","@id":"https:\/\/statorials.org\/it\/#website","url":"https:\/\/statorials.org\/it\/","name":"Statorials","description":"La tua guida all&#039;alfabetizzazione statistica!","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/statorials.org\/it\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"it-IT"},{"@type":"Person","@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/0896f191fb9fb019f2cd8623112cb3ae","name":"Benjamin anderson","image":{"@type":"ImageObject","inLanguage":"it-IT","@id":"https:\/\/statorials.org\/it\/#\/schema\/person\/image\/","url":"https:\/\/statorials.org\/it\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","contentUrl":"https:\/\/statorials.org\/it\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","caption":"Benjamin anderson"},"description":"Ciao, sono Benjamin, un professore di statistica in pensione diventato insegnante dedicato di Statorials. Con una vasta esperienza e competenza nel campo della statistica, sono ansioso di condividere le mie conoscenze per potenziare gli studenti attraverso Statorials. Scopri di pi\u00f9","sameAs":["https:\/\/statorials.org\/it"]}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"_links":{"self":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts\/4990"}],"collection":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/comments?post=4990"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/posts\/4990\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/media?parent=4990"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/categories?post=4990"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/it\/wp-json\/wp\/v2\/tags?post=4990"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}