LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Open TXT file

On May 16, 1:12 pm, Ric0999 wrote:
Hi,

How do i call and open a txt file (Notepade) using macro?

Tks in advance.


What do you want to do with the content? Parse it into cells (rows/
columns)? Us it in a macro as data? Reformat it and write it out to
another file? or what?

To have the text data parsed into the rows and columns of a
spreadsheet you may want to invoke the Data Import function or you
might just want to use the Workbook.OpenText to access it. If it
needs to be parsed and placed in cells, you might want to use the VBA
Open and Read functions.

Knowing something about what the data looks like and what you want to
do with it would go a long way towards providing the most beneficial
answer.

For example, I just opened Excel and recorded a macro to access a
space and comma delimited set of data in a text file and I got
something like this ...

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 5/16/2008 by Tom Lavedas
'
ChDir "C:\Documents and Settings\username\My Documents\"
Workbooks.OpenText Filename:= _
"C:\Documents and Settings\username\My Documents\MyData.txt" _
, Origin:=437, StartRow:=1, DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True, _
Tab:=True, Semicolon:=False, _
Comma:=True, Space:=True, Other:=False, _
FieldInfo:=Array(Array(1, 1), _
Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6,
1)),_
TrailingMinusNumbers:=True
End Sub

That might serve you or it might not. There's just no way to tell
without more info.

Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to open a 82 KB XLSM file due to "Too many different cellformats" & "Converter failed to open the file." errors. Phillip Pi Setting up and Configuration of Excel 0 April 23rd 09 08:53 PM
In Excel - Use Windows Explorer instead of File Open to open file KymY Excel Discussion (Misc queries) 1 August 5th 06 09:59 PM
Open a file do a macro ( made) and open next succesive file SVTman74 Excel Programming 5 April 21st 06 10:14 PM
Open File or Switch Between Windows if File is Open Ricky Pang Excel Programming 2 July 8th 05 05:51 AM
Open File or Switch Between Windows if File is Open Ricky Pang Excel Programming 0 July 2nd 05 08:41 PM


All times are GMT +1. The time now is 05:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"