Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old December 24th, 2017, 02:13 AM
Registered User
Join Date: Dec 2017
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default import text files to excel

i am importing files using this vbascript

Sub Import_All_Text_Files()

Application.ScreenUpdating = False

Dim thisRow As Long
Dim fileNum As Integer
Dim strInput As String

Const strPath As String = "C:\Temp\Temp\" 'Change as required
Dim strFilename As String

strFilename = Dir(strPath & "*.txt")

With ActiveSheet
thisRow = .Range("A" & .Rows.Count).End(xlUp).Row

Do While strFilename <> ""

fileNum = FreeFile()
Open strPath & strFilename For Binary As #fileNum
strInput = Space$(LOF(fileNum))
Get #fileNum, , strInput
Close #fileNum

thisRow = thisRow + 1
.Cells(thisRow, 1).Value = strInput

strFilename = Dir
End With

Application.ScreenUpdating = True
End Sub

but the problem is i can't able to import other language text files. so please add utf-8 code to this script so i can import all text files in any language.

Similar Threads
Thread Thread Starter Forum Replies Last Post
Import from Excel sheet to a text file zone Excel VBA 1 July 26th, 2007 10:34 AM
import data from text file to excel(VBA) topr Excel VBA 2 August 26th, 2004 11:36 PM
Excel IMport Text Help!! money Excel VBA 2 April 30th, 2004 12:43 AM
Excel text Import and VB Franck Excel VBA 0 January 8th, 2004 09:57 AM
import .doc files text in access jf17 Access 1 December 10th, 2003 03:58 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.