Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default opening an existing text file useing code

hay any one help me in opening an existing txt files with a macro or
VBA coding.

like i have differrent txt files in differrent file if open those file
each txt file will be opened in one excel but i want all of them to be
opened in the same excel file but in differrent sheets.

and one more thing if we open a text file in excel it will ask us for
the coulumn and row breaks i want to skip that as my default delimitar
is a space

thank you

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 989
Default opening an existing text file useing code

I think you have to open them separately, but after you open the second one,
just move it the same workbook as the first.

The last line in this code performs the move:

Sub sbTwoTextFiles()

'dimension variables

Dim wsDest As Worksheet


'open first text file

Workbooks.OpenText Filename:="C:\text1.txt", StartRow:=1, _
DataType:=xlDelimited, ConsecutiveDelimiter _
:=False, Tab:=False, Semicolon:=False, Comma:=False, Space:=True


'set worksheet variable to first text sheet

Set wsDest = ActiveSheet


'open second text file

Workbooks.OpenText Filename:="C:\text2.txt", StartRow:=1, _
DataType:=xlDelimited, ConsecutiveDelimiter:=False, Tab:=False, _
Semicolon:=False, Comma:=False, Space:=True


'move text file to sheet after first text file

ActiveSheet.Move After:=wsDest

End Sub




"ramki" wrote:

hay any one help me in opening an existing txt files with a macro or
VBA coding.

like i have differrent txt files in differrent file if open those file
each txt file will be opened in one excel but i want all of them to be
opened in the same excel file but in differrent sheets.

and one more thing if we open a text file in excel it will ask us for
the coulumn and row breaks i want to skip that as my default delimitar
is a space

thank you


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default opening an existing text file useing code


What kind of text file?
Flat ascii (all of the records and fields run together), CSV (comma
separated values -- not necessarily commas, it could be tabs, periods,
quotes, etc.) or some other format?

It matters because it determines the options you have to import data
into Excel. Whereas text files have to be "imported".


--
bgeier
------------------------------------------------------------------------
bgeier's Profile: http://www.excelforum.com/member.php...o&userid=12822
View this thread: http://www.excelforum.com/showthread...hreadid=543616

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default opening an existing text file useing code

it is a plain text file which contains numbers seperated by tabs in the
coulumns.


give me a reply

Reply
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
opening new csv file in existing xls file's worksheet Shikha Excel Worksheet Functions 4 March 2nd 09 12:56 PM
on opening an existing file I get blank blue screen Paul de Vos Excel Worksheet Functions 1 February 13th 09 05:42 PM
Excel 2007 blank when opening existing file Syrena Excel Discussion (Misc queries) 3 October 1st 08 03:11 AM
opening an existing file Like the morning Excel Discussion (Misc queries) 5 June 12th 08 07:41 PM
Opening an existing Word File from within Excel AJO[_4_] Excel Programming 0 February 13th 06 07:15 PM


All times are GMT +1. The time now is 09:11 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"