R
rraajjiibb
Iam importing using VBA contents of a file into excel. Since the fil
does't have line feeds I need to bring it into word insert linefeed an
then save it as a text file and finally extract the data out of it int
excel.But it is struck in the open statement in word.
Could any body help.
Sub ImportLargeTextFile()
Set INWORD = CreateObject("Word.Application")
'if I just put the file name the format in which it is saved is do
file formatand i cannot use it
Set CURRENT = INWORD.Documents.Open(FILENAME:= _
"smd.040113_03.done.x_FLY-PROCESSED_x.13_01_2004_03_31_10", _
ConfirmConversions:=False, ReadOnly:=False
AddToRecentFiles:=False, _
PasswordDocument:="", PasswordTemplate:="", Revert:=False, _
WritePasswordDocument:="", WritePasswordTemplate:="", Format:
_
wdOpenFormatAuto)
CURRENT.SaveAs FILENAME:= _
"C:\all_cell_data\smd.040113_11.done.x_FLY-PROCESSED_x.13_01_2004_11_31_24.txt"
_
FileFormat:=wdFormatTextLineBreaks, LockComments:=False
Password:="", _
AddToRecentFiles:=True, WritePassword:=""
ReadOnlyRecommended:=False, _
EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False
SaveFormsData _
:=False, SaveAsAOCELetter:=False
Set INWORD = Nothing
Set CURRENT = Nothing
Dim tmpStr As String
Dim f As Integer
Dim CurrentRow As Long
FILEPATH = Application.GetOpenFilename
'"C:\all_cell_data\smd.040113_01.done.x_FLY-PROCESSED_x.13_01_2004_01_31_34
'change to your file
Application.ScreenUpdating = False
f = FreeFile
CurrentRow = 1
Open FILEPATH For Input As #f
Workbooks.Add TEMPLATE:=xlWorksheet
Do While Not EOF(f)
If Not (CurrentRow <= ActiveSheet.Rows.Count) Then
ActiveWorkbook.Sheets.Add After:=ActiveSheet
CurrentRow = 1
End If
Input #f, tmpStr
ActiveSheet.Cells(CurrentRow, 1) = tmpStr
CurrentRow = CurrentRow + 1
Loop
Close #f
Application.ScreenUpdating = True
End Su
does't have line feeds I need to bring it into word insert linefeed an
then save it as a text file and finally extract the data out of it int
excel.But it is struck in the open statement in word.
Could any body help.
Sub ImportLargeTextFile()
Set INWORD = CreateObject("Word.Application")
'if I just put the file name the format in which it is saved is do
file formatand i cannot use it
Set CURRENT = INWORD.Documents.Open(FILENAME:= _
"smd.040113_03.done.x_FLY-PROCESSED_x.13_01_2004_03_31_10", _
ConfirmConversions:=False, ReadOnly:=False
AddToRecentFiles:=False, _
PasswordDocument:="", PasswordTemplate:="", Revert:=False, _
WritePasswordDocument:="", WritePasswordTemplate:="", Format:
_
wdOpenFormatAuto)
CURRENT.SaveAs FILENAME:= _
"C:\all_cell_data\smd.040113_11.done.x_FLY-PROCESSED_x.13_01_2004_11_31_24.txt"
_
FileFormat:=wdFormatTextLineBreaks, LockComments:=False
Password:="", _
AddToRecentFiles:=True, WritePassword:=""
ReadOnlyRecommended:=False, _
EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False
SaveFormsData _
:=False, SaveAsAOCELetter:=False
Set INWORD = Nothing
Set CURRENT = Nothing
Dim tmpStr As String
Dim f As Integer
Dim CurrentRow As Long
FILEPATH = Application.GetOpenFilename
'"C:\all_cell_data\smd.040113_01.done.x_FLY-PROCESSED_x.13_01_2004_01_31_34
'change to your file
Application.ScreenUpdating = False
f = FreeFile
CurrentRow = 1
Open FILEPATH For Input As #f
Workbooks.Add TEMPLATE:=xlWorksheet
Do While Not EOF(f)
If Not (CurrentRow <= ActiveSheet.Rows.Count) Then
ActiveWorkbook.Sheets.Add After:=ActiveSheet
CurrentRow = 1
End If
Input #f, tmpStr
ActiveSheet.Cells(CurrentRow, 1) = tmpStr
CurrentRow = CurrentRow + 1
Loop
Close #f
Application.ScreenUpdating = True
End Su