Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 49906

copy text via notepad to excel worksheet

$
0
0
I need to populate a excel worksheet with data from a tab delimited text file.
This can be done many ways.
The issue I have is that the the text file contains a mix of english and japanese characters in various columns and rows.
The file is approx 50mb with 35,000= rows by 100+ columns.

When I have imported the text file into excel, whete the japanese characters ocur, the delimiting of the file fails. Resulting in data being forced accross to other columns or onto new row, with actual loss of the japanese charcters in proper format, resulting in corruption of the data for my purpose.
I cant change the content of the text file in any way (being output from another system).
I have tried various changes to TextFilePlatform parameter with no success.

The only sucessful technique that produces desired result is to manually open file via notepad, select all, copy and paste to worksheet.

So unless there is a solution via excel import methods, I would like to automate the manual notepad process.
The only issue I have experinced is how to get excel vba to wait for open and display of text file content in full before executing sendkeys select, copy then paste to excel.

So any ideas how to do the wait.
I was going to use sendkeys to do the select, copy & paste - unless there is a better way.

Any ideas people ?

Code:

Sub OpenNotepadFile()
    Dim retval As Variant
    FName = "C:\test text file to import.txt"

    ' open notepad file
    retval = Shell("notepad.exe " & FName, vbMaximizedFocus)

    ' wait for file to open and display in full
    ' ???????
   
    ' select all, copy & paste to excel stuff
   
    MsgBox "Done"
End Sub


Viewing all articles
Browse latest Browse all 49906

Trending Articles