Using open statement in word from excel

  • Thread starter Thread starter rraajjiibb
  • Start date Start date
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
 
Hi Rraajjiibb,
am importing using VBA contents of a file into excel. Since the file
does't have line feeds I need to bring it into word insert linefeed and
then save it as a text file and finally extract the data out of it into
excel.But it is struck in the open statement in word.
I suspect we're hitting a language barrier, here... It's not clear (to
me, anyway) exactly what the problem is. I can see you're opening a Word
document? And then trying to save it as a special kind of text file. But
what, exactly, is the problem? Are you getting an error message on the
Documents.Open command? If yes, what is it - EXACTLY?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :-)
 
Cindy,
I have new machine with XP Pro, can you tell me how to use
the speach recognition features in XP to dictate into a
word doc??

Thank you, Butch
 
Back
Top