copy paste - Copying lines from Wordpad into Excel using VBA -


i writing code import files under tmx (a form of xml). tried various options

a) using open filename input, messes character encoding

b) opening file , copying data using msodialog, return error if file large (which case) , put data in utterly messy manner.

c) opening file using notepad, there same limitations in far copying entirety of file excel previous option. not trying use shell function calling onto wordpad.

my issue right now, need copy file line line treat content according needs (hopefully without losing character encoding

would know how copy every single line file opened in wordpad , paste post treatment (selection of relevant elements) excel?

thank you

for large files can use solution:

public sub importtmxtoexcel()  call application.filedialog(msofiledialogopen).filters.clear call application.filedialog(msofiledialogopen).filters.add("tmx files", "*.tmx") application.filedialog(msofiledialogopen).title = "select file import..." application.filedialog(msofiledialogopen).allowmultiselect = false intchoice = application.filedialog(msofiledialogopen).show if intchoice <> 0     strfiletoimport = application.filedialog(msofiledialogopen).selecteditems(1) else     exit sub end if  intpointer = freefile() open strfiletoimport input access read lock read #intpointer  intcounter = 0 until eof(intpointer)     line input #intpointer, strline     intcounter = intcounter + 1     worksheets(1).cells(intcounter + 1, 1).value2 = strline loop  close intpointer  end sub 

for other encodings can use ado's stream described in solution: vb6/vbscript change file encoding ansi

if have large files require ado's stream might want consider breaking down large files first described in solution: how split large text file smaller files equal number of lines?

the following website provides tool mimics unix command split windows in command prompt: https://www.fourmilab.ch/splits/


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -